Skip to content

Commit b34ad7e

Browse files
committed
test: fix websocket upgrade lint issues
1 parent b001e88 commit b34ad7e

3 files changed

Lines changed: 26 additions & 18 deletions

File tree

lib/internal/http_websocket_observer.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ const {
55
ArrayPrototypeIncludes,
66
Boolean,
77
NumberIsSafeInteger,
8-
RegExpPrototypeExec,
98
ReflectApply,
9+
RegExpPrototypeExec,
1010
Symbol,
1111
} = primordials;
1212

@@ -261,7 +261,7 @@ class WebSocketObserver {
261261
if (this.receivedParser !== undefined && this.readable?.push) {
262262
this.originalPush = this.readable.push;
263263
const observer = this;
264-
this.readable.push = function observedReadablePush(chunk, encoding) {
264+
this.readable.push = function push(chunk, encoding) {
265265
observer.observeReceivedChunk(chunk, encoding);
266266
return ReflectApply(observer.originalPush, this, arguments);
267267
};
@@ -270,7 +270,7 @@ class WebSocketObserver {
270270
if (this.sentParser !== undefined && this.writable?.write) {
271271
this.originalWrite = this.writable.write;
272272
const observer = this;
273-
this.writable.write = function observedWritableWrite(chunk, encoding, callback) {
273+
this.writable.write = function write(chunk, encoding, callback) {
274274
observer.observeSentChunk(chunk, encoding);
275275
return ReflectApply(observer.originalWrite, this, arguments);
276276
};
@@ -383,8 +383,12 @@ function observeClientWebSocketUpgrade(request, response, socket, head) {
383383
primary: socket,
384384
readable: socket,
385385
writable: socket,
386-
onFrameReceived: observeReceived ? onClientFrameReceivedChannel.publish.bind(onClientFrameReceivedChannel) : undefined,
387-
onFrameSent: observeSent ? onClientFrameSentChannel.publish.bind(onClientFrameSentChannel) : undefined,
386+
onFrameReceived: observeReceived ?
387+
onClientFrameReceivedChannel.publish.bind(onClientFrameReceivedChannel) :
388+
undefined,
389+
onFrameSent: observeSent ?
390+
onClientFrameSentChannel.publish.bind(onClientFrameSentChannel) :
391+
undefined,
388392
});
389393
socket[kObserverState] = observer;
390394
observer.enable(head);
@@ -427,8 +431,12 @@ function observeServerWebSocketUpgrade(request, socketOrStream, socket, head, pa
427431
primary: socketOrStream,
428432
readable: socketOrStream,
429433
writable: socketOrStream,
430-
onFrameReceived: observeReceived ? onServerFrameReceivedChannel.publish.bind(onServerFrameReceivedChannel) : undefined,
431-
onFrameSent: observeSent ? onServerFrameSentChannel.publish.bind(onServerFrameSentChannel) : undefined,
434+
onFrameReceived: observeReceived ?
435+
onServerFrameReceivedChannel.publish.bind(onServerFrameReceivedChannel) :
436+
undefined,
437+
onFrameSent: observeSent ?
438+
onServerFrameSentChannel.publish.bind(onServerFrameSentChannel) :
439+
undefined,
432440
skipHttpUpgradeResponse: observeSent,
433441
});
434442
socketOrStream[kObserverState] = observer;

test/parallel/test-diagnostics-channel-http-server-upgrade-websocket.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ server.listen(0, '127.0.0.1', common.mustCall(async () => {
164164
'Upgrade: websocket\r\n' +
165165
'Content-Length: 0\r\n' +
166166
'\r\n', {
167-
initialTail: completeHeadFrame,
168-
closeFrame,
169-
});
167+
initialTail: completeHeadFrame,
168+
closeFrame,
169+
});
170170

171171
await runClient(port,
172172
'POST /incomplete HTTP/1.1\r\n' +
@@ -176,12 +176,12 @@ server.listen(0, '127.0.0.1', common.mustCall(async () => {
176176
'Transfer-Encoding: chunked\r\n' +
177177
'Trailer: X-Test\r\n' +
178178
'\r\n', {
179-
secondWrite: Buffer.concat([
180-
Buffer.from('4\r\nbody\r\n0\r\nX-Test: yes\r\n\r\n', 'latin1'),
181-
incompleteBodyFrame,
182-
]),
183-
closeFrame,
184-
});
179+
secondWrite: Buffer.concat([
180+
Buffer.from('4\r\nbody\r\n0\r\nX-Test: yes\r\n\r\n', 'latin1'),
181+
incompleteBodyFrame,
182+
]),
183+
closeFrame,
184+
});
185185

186186
server.close();
187187
}));

test/parallel/test-inspector-network-http-upgrade-websocket.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ async function test() {
119119
host,
120120
port: server.port,
121121
headers: {
122-
Connection: 'Upgrade',
123-
Upgrade: 'websocket',
122+
'Connection': 'Upgrade',
123+
'Upgrade': 'websocket',
124124
'Sec-WebSocket-Key': 'dGhlIHNhbXBsZSBub25jZQ==',
125125
'Sec-WebSocket-Version': '13',
126126
},

0 commit comments

Comments
 (0)