Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bc66356

Browse filesBrowse files
sam-githubtargos
authored andcommitted
src: use consistent names for JSStream
Its confusing to call a js class with a handle a "Wrap", usually it's the C++ handle that is called a Wrap (tcp_wrap, tls_wrap, ...). Its derived from Socket, and makes a JS stream look like a Socket, so call it that. Also, remove use of lib/_stream_wrap.js so it can be deprecated some time. PR-URL: #25153 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
1 parent f6b2ea8 commit bc66356
Copy full SHA for bc66356
Expand file treeCollapse file tree

12 files changed

+28
-22
lines changed
Open diff view settings
Collapse file

‎lib/_stream_wrap.js‎

Copy file name to clipboard
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
'use strict';
22

3-
module.exports = require('internal/wrap_js_stream');
3+
module.exports = require('internal/js_stream_socket');
Collapse file

‎lib/_tls_wrap.js‎

Copy file name to clipboardExpand all lines: lib/_tls_wrap.js
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const net = require('net');
2929
const tls = require('tls');
3030
const util = require('util');
3131
const common = require('_tls_common');
32-
const { StreamWrap } = require('_stream_wrap');
32+
const JSStreamSocket = require('internal/js_stream_socket');
3333
const { Buffer } = require('buffer');
3434
const debug = util.debuglog('tls');
3535
const { TCP, constants: TCPConstants } = internalBinding('tcp_wrap');
@@ -308,12 +308,14 @@ function TLSSocket(socket, opts) {
308308
this.authorizationError = null;
309309
this[kRes] = null;
310310

311-
// Wrap plain JS Stream into StreamWrap
312311
var wrap;
313312
if ((socket instanceof net.Socket && socket._handle) || !socket) {
314313
wrap = socket;
315314
} else {
316-
wrap = new StreamWrap(socket);
315+
// TLS expects to interact from C++ with a net.Socket that has a C++ stream
316+
// handle, but a JS stream doesn't have one. Wrap it up to make it look like
317+
// a socket.
318+
wrap = new JSStreamSocket(socket);
317319
wrap.once('close', () => this.destroy());
318320
}
319321

Collapse file

‎lib/internal/http2/core.js‎

Copy file name to clipboardExpand all lines: lib/internal/http2/core.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const util = require('util');
2222

2323
const { kIncomingMessage } = require('_http_common');
2424
const { kServerResponse } = require('_http_server');
25-
const { StreamWrap } = require('_stream_wrap');
25+
const JSStreamSocket = require('internal/js_stream_socket');
2626

2727
const {
2828
defaultTriggerAsyncIdScope,
@@ -935,7 +935,7 @@ class Http2Session extends EventEmitter {
935935
super();
936936

937937
if (!socket._handle || !socket._handle._externalStream) {
938-
socket = new StreamWrap(socket);
938+
socket = new JSStreamSocket(socket);
939939
}
940940

941941
// No validation is performed on the input parameters because this
Collapse file
+8-7Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const util = require('util');
55
const { Socket } = require('net');
66
const { JSStream } = internalBinding('js_stream');
77
const uv = internalBinding('uv');
8-
const debug = util.debuglog('stream_wrap');
8+
const debug = util.debuglog('stream_socket');
99
const { owner_symbol } = require('internal/async_hooks').symbols;
1010
const { ERR_STREAM_WRAP } = require('internal/errors').codes;
1111

@@ -29,17 +29,17 @@ function onwrite(req, bufs) { return this[owner_symbol].doWrite(req, bufs); }
2929
* can skip going through the JS layer and let TLS access the raw C++ handle
3030
* of a net.Socket. The flipside of this is that, to maintain composability,
3131
* we need a way to create "fake" net.Socket instances that call back into a
32-
* "real" JavaScript stream. JSStreamWrap is exactly this.
32+
* "real" JavaScript stream. JSStreamSocket is exactly this.
3333
*/
34-
class JSStreamWrap extends Socket {
34+
class JSStreamSocket extends Socket {
3535
constructor(stream) {
3636
const handle = new JSStream();
3737
handle.close = (cb) => {
3838
debug('close');
3939
this.doClose(cb);
4040
};
4141
// Inside of the following functions, `this` refers to the handle
42-
// and `this[owner_symbol]` refers to this JSStreamWrap instance.
42+
// and `this[owner_symbol]` refers to this JSStreamSocket instance.
4343
handle.isClosing = isClosing;
4444
handle.onreadstart = onreadstart;
4545
handle.onreadstop = onreadstop;
@@ -88,9 +88,10 @@ class JSStreamWrap extends Socket {
8888
this.read(0);
8989
}
9090

91-
// Legacy
91+
// Allow legacy requires in the test suite to keep working:
92+
// const { StreamWrap } = require('internal/js_stream_socket')
9293
static get StreamWrap() {
93-
return JSStreamWrap;
94+
return JSStreamSocket;
9495
}
9596

9697
isClosing() {
@@ -223,4 +224,4 @@ class JSStreamWrap extends Socket {
223224
}
224225
}
225226

226-
module.exports = JSStreamWrap;
227+
module.exports = JSStreamSocket;
Collapse file

‎node.gyp‎

Copy file name to clipboardExpand all lines: node.gyp
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
'lib/internal/fs/watchers.js',
125125
'lib/internal/http.js',
126126
'lib/internal/inspector_async_hook.js',
127+
'lib/internal/js_stream_socket.js',
127128
'lib/internal/linkedlist.js',
128129
'lib/internal/modules/cjs/helpers.js',
129130
'lib/internal/modules/cjs/loader.js',
@@ -186,7 +187,6 @@
186187
'lib/internal/streams/state.js',
187188
'lib/internal/streams/pipeline.js',
188189
'lib/internal/streams/end-of-stream.js',
189-
'lib/internal/wrap_js_stream.js',
190190
'deps/v8/tools/splaytree.js',
191191
'deps/v8/tools/codemap.js',
192192
'deps/v8/tools/consarray.js',
Collapse file

‎test/parallel/test-stream-wrap-drain.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-stream-wrap-drain.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
'use strict';
33
const common = require('../common');
44
const assert = require('assert');
5-
const { StreamWrap } = require('_stream_wrap');
5+
const { StreamWrap } = require('internal/js_stream_socket');
66
const { Duplex } = require('stream');
77
const { internalBinding } = require('internal/test/binding');
88
const { ShutdownWrap } = internalBinding('stream_wrap');
99

10-
// This test makes sure that when an instance of JSStreamWrap is waiting for
10+
// This test makes sure that when a wrapped stream is waiting for
1111
// a "drain" event to `doShutdown`, the instance will work correctly when a
1212
// "drain" event emitted.
1313
{
Collapse file

‎test/parallel/test-stream-wrap-encoding.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-stream-wrap-encoding.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
// Flags: --expose-internals
12
'use strict';
23
const common = require('../common');
34

4-
const StreamWrap = require('_stream_wrap');
5+
const StreamWrap = require('internal/js_stream_socket');
56
const Duplex = require('stream').Duplex;
67

78
{
Collapse file

‎test/parallel/test-stream-wrap.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-stream-wrap.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const common = require('../common');
44
const assert = require('assert');
55

66
const { internalBinding } = require('internal/test/binding');
7-
const StreamWrap = require('_stream_wrap');
7+
const StreamWrap = require('internal/js_stream_socket');
88
const { Duplex } = require('stream');
99
const { ShutdownWrap } = internalBinding('stream_wrap');
1010

Collapse file

‎test/parallel/test-wrap-js-stream-destroy.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-wrap-js-stream-destroy.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
// Flags: --expose-internals
12
'use strict';
23

34
const common = require('../common');
4-
const StreamWrap = require('_stream_wrap');
5+
const StreamWrap = require('internal/js_stream_socket');
56
const net = require('net');
67

78
// This test ensures that when we directly call `socket.destroy()` without
Collapse file

‎test/parallel/test-wrap-js-stream-duplex.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-wrap-js-stream-duplex.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
// Flags: --expose-internals
12
'use strict';
23
const common = require('../common');
34
const assert = require('assert');
4-
const StreamWrap = require('_stream_wrap');
5+
const StreamWrap = require('internal/js_stream_socket');
56
const { PassThrough } = require('stream');
67
const { Socket } = require('net');
78

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.