diff --git a/docs/api/Debug.md b/docs/api/Debug.md new file mode 100644 index 00000000000..1a1794c0ad9 --- /dev/null +++ b/docs/api/Debug.md @@ -0,0 +1,62 @@ +# Debug + +Undici (and subsenquently `fetch` and `websocket`) exposes a debug statement that can be enabled by setting `NODE_DEBUG` within the environment. + +The flags availabile are: + +## `undici` + +This flag enables debug statements for the core undici library. + +```sh +NODE_DEBUG=undici node script.js + +UNDICI 16241: connecting to nodejs.org using https:h1 +UNDICI 16241: connecting to nodejs.org using https:h1 +UNDICI 16241: connected to nodejs.org using https:h1 +UNDICI 16241: sending request to GET https://nodejs.org// +UNDICI 16241: received response to GET https://nodejs.org// - HTTP 307 +UNDICI 16241: connecting to nodejs.org using https:h1 +UNDICI 16241: trailers received from GET https://nodejs.org// +UNDICI 16241: connected to nodejs.org using https:h1 +UNDICI 16241: sending request to GET https://nodejs.org//en +UNDICI 16241: received response to GET https://nodejs.org//en - HTTP 200 +UNDICI 16241: trailers received from GET https://nodejs.org//en +``` + +## `fetch` + +This flag enables debug statements for the `fetch` API. + +> **Note**: statements are pretty similar to the ones in the `undici` flag, but scoped to `fetch` + +```sh +NODE_DEBUG=fetch node script.js + +FETCH 16241: connecting to nodejs.org using https:h1 +FETCH 16241: connecting to nodejs.org using https:h1 +FETCH 16241: connected to nodejs.org using https:h1 +FETCH 16241: sending request to GET https://nodejs.org// +FETCH 16241: received response to GET https://nodejs.org// - HTTP 307 +FETCH 16241: connecting to nodejs.org using https:h1 +FETCH 16241: trailers received from GET https://nodejs.org// +FETCH 16241: connected to nodejs.org using https:h1 +FETCH 16241: sending request to GET https://nodejs.org//en +FETCH 16241: received response to GET https://nodejs.org//en - HTTP 200 +FETCH 16241: trailers received from GET https://nodejs.org//en +``` + +## `websocket` + +This flag enables debug statements for the `Websocket` API. + +> **Note**: statements can overlap with `UNDICI` ones if `undici` or `fetch` flag has been enabled as well. + +```sh +NODE_DEBUG=fetch node script.js + +WEBSOCKET 18309: connecting to echo.websocket.org using https:h1 +WEBSOCKET 18309: connected to echo.websocket.org using https:h1 +WEBSOCKET 18309: sending request to GET https://echo.websocket.org// +WEBSOCKET 18309: connection opened +``` \ No newline at end of file diff --git a/docs/api/DiagnosticsChannel.md b/docs/api/DiagnosticsChannel.md index 0aa0b9a0783..6e6ad6e4de8 100644 --- a/docs/api/DiagnosticsChannel.md +++ b/docs/api/DiagnosticsChannel.md @@ -105,7 +105,7 @@ You can not assume that this event is related to any specific request. import diagnosticsChannel from 'diagnostics_channel' diagnosticsChannel.channel('undici:client:beforeConnect').subscribe(({ connectParams, connector }) => { - // const { host, hostname, protocol, port, servername } = connectParams + // const { host, hostname, protocol, port, servername, version } = connectParams // connector is a function that creates the socket }) ``` @@ -118,7 +118,7 @@ This message is published after a connection is established. import diagnosticsChannel from 'diagnostics_channel' diagnosticsChannel.channel('undici:client:connected').subscribe(({ socket, connectParams, connector }) => { - // const { host, hostname, protocol, port, servername } = connectParams + // const { host, hostname, protocol, port, servername, version } = connectParams // connector is a function that creates the socket }) ``` @@ -131,7 +131,7 @@ This message is published if it did not succeed to create new connection import diagnosticsChannel from 'diagnostics_channel' diagnosticsChannel.channel('undici:client:connectError').subscribe(({ error, socket, connectParams, connector }) => { - // const { host, hostname, protocol, port, servername } = connectParams + // const { host, hostname, protocol, port, servername, version } = connectParams // connector is a function that creates the socket console.log(`Connect failed with ${error.message}`) }) diff --git a/docsify/sidebar.md b/docsify/sidebar.md index 35d5c614ce5..d5bd69a219c 100644 --- a/docsify/sidebar.md +++ b/docsify/sidebar.md @@ -18,6 +18,7 @@ * [MockErrors](/docs/api/MockErrors.md "Undici API - MockErrors") * [API Lifecycle](/docs/api/api-lifecycle.md "Undici API - Lifecycle") * [Diagnostics Channel Support](/docs/api/DiagnosticsChannel.md "Diagnostics Channel Support") + * [Debug](/docs/api/Debug.md.md "Undici API - Debugging Undici") * [WebSocket](/docs/api/WebSocket.md "Undici API - WebSocket") * [MIME Type Parsing](/docs/api/ContentType.md "Undici API - MIME Type Parsing") * [CacheStorage](/docs/api/CacheStorage.md "Undici API - CacheStorage") diff --git a/lib/client.js b/lib/client.js index 25f3478490e..cc5c4890552 100644 --- a/lib/client.js +++ b/lib/client.js @@ -9,6 +9,7 @@ const net = require('net') const http = require('http') const { pipeline } = require('stream') const util = require('./core/util') +const { channels } = require('./core/diagnostics') const timers = require('./timers') const Request = require('./core/request') const DispatcherBase = require('./dispatcher-base') @@ -108,21 +109,6 @@ const FastBuffer = Buffer[Symbol.species] const kClosedResolve = Symbol('kClosedResolve') -const channels = {} - -try { - const diagnosticsChannel = require('diagnostics_channel') - channels.sendHeaders = diagnosticsChannel.channel('undici:client:sendHeaders') - channels.beforeConnect = diagnosticsChannel.channel('undici:client:beforeConnect') - channels.connectError = diagnosticsChannel.channel('undici:client:connectError') - channels.connected = diagnosticsChannel.channel('undici:client:connected') -} catch { - channels.sendHeaders = { hasSubscribers: false } - channels.beforeConnect = { hasSubscribers: false } - channels.connectError = { hasSubscribers: false } - channels.connected = { hasSubscribers: false } -} - /** * @type {import('../types/client').default} */ @@ -1191,6 +1177,7 @@ async function connect (client) { hostname, protocol, port, + version: client[kHTTPConnVersion], servername: client[kServerName], localAddress: client[kLocalAddress] }, @@ -1284,6 +1271,7 @@ async function connect (client) { hostname, protocol, port, + version: client[kHTTPConnVersion], servername: client[kServerName], localAddress: client[kLocalAddress] }, @@ -1306,6 +1294,7 @@ async function connect (client) { hostname, protocol, port, + version: client[kHTTPConnVersion], servername: client[kServerName], localAddress: client[kLocalAddress] }, diff --git a/lib/core/diagnostics.js b/lib/core/diagnostics.js new file mode 100644 index 00000000000..e76f73a8c3a --- /dev/null +++ b/lib/core/diagnostics.js @@ -0,0 +1,202 @@ +'use strict' +const diagnosticsChannel = require('diagnostics_channel') +const util = require('util') + +const undiciDebugLog = util.debuglog('undici') +const fetchDebuglog = util.debuglog('fetch') +const websocketDebuglog = util.debuglog('websocket') +let isClientSet = false +const channels = { + // Client + beforeConnect: diagnosticsChannel.channel('undici:client:beforeConnect'), + connected: diagnosticsChannel.channel('undici:client:connected'), + connectError: diagnosticsChannel.channel('undici:client:connectError'), + sendHeaders: diagnosticsChannel.channel('undici:client:sendHeaders'), + // Request + create: diagnosticsChannel.channel('undici:request:create'), + bodySent: diagnosticsChannel.channel('undici:request:bodySent'), + headers: diagnosticsChannel.channel('undici:request:headers'), + trailers: diagnosticsChannel.channel('undici:request:trailers'), + error: diagnosticsChannel.channel('undici:request:error'), + // WebSocket + open: diagnosticsChannel.channel('undici:websocket:open'), + close: diagnosticsChannel.channel('undici:websocket:close'), + socketError: diagnosticsChannel.channel('undici:websocket:socket_error'), + ping: diagnosticsChannel.channel('undici:websocket:ping'), + pong: diagnosticsChannel.channel('undici:websocket:pong') +} + +if (undiciDebugLog.enabled || fetchDebuglog.enabled) { + const debuglog = fetchDebuglog.enabled ? fetchDebuglog : undiciDebugLog + + // Track all Client events + diagnosticsChannel.channel('undici:client:beforeConnect').subscribe(evt => { + const { + connectParams: { version, protocol, port, host } + } = evt + debuglog( + 'connecting to %s using %s%s', + `${host}${port ? `:${port}` : ''}`, + protocol, + version + ) + }) + + diagnosticsChannel.channel('undici:client:connected').subscribe(evt => { + const { + connectParams: { version, protocol, port, host } + } = evt + debuglog( + 'connected to %s using %s%s', + `${host}${port ? `:${port}` : ''}`, + protocol, + version + ) + }) + + diagnosticsChannel.channel('undici:client:connectError').subscribe(evt => { + const { + connectParams: { version, protocol, port, host }, + error + } = evt + debuglog( + 'connection to %s using %s%s errored - %s', + `${host}${port ? `:${port}` : ''}`, + protocol, + version, + error.message + ) + }) + + diagnosticsChannel.channel('undici:client:sendHeaders').subscribe(evt => { + const { + request: { method, path, origin } + } = evt + debuglog('sending request to %s %s/%s', method, origin, path) + }) + + // Track Request events + diagnosticsChannel.channel('undici:request:headers').subscribe(evt => { + const { + request: { method, path, origin }, + response: { statusCode } + } = evt + debuglog( + 'received response to %s %s/%s - HTTP %d', + method, + origin, + path, + statusCode + ) + }) + + diagnosticsChannel.channel('undici:request:trailers').subscribe(evt => { + const { + request: { method, path, origin } + } = evt + debuglog('trailers received from %s %s/%s', method, origin, path) + }) + + diagnosticsChannel.channel('undici:request:error').subscribe(evt => { + const { + request: { method, path, origin }, + error + } = evt + debuglog( + 'request to %s %s/%s errored - %s', + method, + origin, + path, + error.message + ) + }) + + isClientSet = true +} + +if (websocketDebuglog.enabled) { + if (!isClientSet) { + const debuglog = undiciDebugLog.enabled ? undiciDebugLog : websocketDebuglog + diagnosticsChannel.channel('undici:client:beforeConnect').subscribe(evt => { + const { + connectParams: { version, protocol, port, host } + } = evt + debuglog( + 'connecting to %s%s using %s%s', + host, + port ? `:${port}` : '', + protocol, + version + ) + }) + + diagnosticsChannel.channel('undici:client:connected').subscribe(evt => { + const { + connectParams: { version, protocol, port, host } + } = evt + debuglog( + 'connected to %s%s using %s%s', + host, + port ? `:${port}` : '', + protocol, + version + ) + }) + + diagnosticsChannel.channel('undici:client:connectError').subscribe(evt => { + const { + connectParams: { version, protocol, port, host }, + error + } = evt + debuglog( + 'connection to %s%s using %s%s errored - %s', + host, + port ? `:${port}` : '', + protocol, + version, + error.message + ) + }) + + diagnosticsChannel.channel('undici:client:sendHeaders').subscribe(evt => { + const { + request: { method, path, origin } + } = evt + debuglog('sending request to %s %s/%s', method, origin, path) + }) + } + + // Track all WebSocket events + diagnosticsChannel.channel('undici:websocket:open').subscribe(evt => { + const { + address: { address, port } + } = evt + websocketDebuglog('connection opened %s%s', address, port ? `:${port}` : '') + }) + + diagnosticsChannel.channel('undici:websocket:close').subscribe(evt => { + const { websocket, code, reason } = evt + websocketDebuglog( + 'closed connection to %s - %s %s', + websocket.url, + code, + reason + ) + }) + + diagnosticsChannel.channel('undici:websocket:socket_error').subscribe(err => { + websocketDebuglog('connection errored - %s', err.message) + }) + + diagnosticsChannel.channel('undici:websocket:ping').subscribe(evt => { + websocketDebuglog('ping received') + }) + + diagnosticsChannel.channel('undici:websocket:pong').subscribe(evt => { + websocketDebuglog('pong received') + }) +} + +module.exports = { + channels +} diff --git a/lib/core/request.js b/lib/core/request.js index fe63434ea98..4a61da0e454 100644 --- a/lib/core/request.js +++ b/lib/core/request.js @@ -7,6 +7,7 @@ const { const assert = require('assert') const { kHTTP2BuildRequest, kHTTP2CopyHeaders, kHTTP1BuildRequest } = require('./symbols') const util = require('./util') +const { channels } = require('./diagnostics.js') const { headerNameLowerCasedRecord } = require('./constants') // headerCharRegex have been lifted from @@ -25,25 +26,8 @@ const invalidPathRegex = /[^\u0021-\u00ff]/ const kHandler = Symbol('handler') -const channels = {} - let extractBody -try { - const diagnosticsChannel = require('diagnostics_channel') - channels.create = diagnosticsChannel.channel('undici:request:create') - channels.bodySent = diagnosticsChannel.channel('undici:request:bodySent') - channels.headers = diagnosticsChannel.channel('undici:request:headers') - channels.trailers = diagnosticsChannel.channel('undici:request:trailers') - channels.error = diagnosticsChannel.channel('undici:request:error') -} catch { - channels.create = { hasSubscribers: false } - channels.bodySent = { hasSubscribers: false } - channels.headers = { hasSubscribers: false } - channels.trailers = { hasSubscribers: false } - channels.error = { hasSubscribers: false } -} - class Request { constructor (origin, { path, diff --git a/lib/websocket/connection.js b/lib/websocket/connection.js index 4bc60b3b90b..d8a4f04f637 100644 --- a/lib/websocket/connection.js +++ b/lib/websocket/connection.js @@ -1,6 +1,5 @@ 'use strict' -const diagnosticsChannel = require('diagnostics_channel') const { uid, states } = require('./constants') const { kReadyState, @@ -9,6 +8,7 @@ const { kReceivedClose } = require('./symbols') const { fireEvent, failWebsocketConnection } = require('./util') +const { channels } = require('../core/diagnostics') const { CloseEvent } = require('./events') const { makeRequest } = require('../fetch/request') const { fetching } = require('../fetch/index') @@ -16,11 +16,6 @@ const { Headers } = require('../fetch/headers') const { getGlobalDispatcher } = require('../global') const { kHeadersList } = require('../core/symbols') -const channels = {} -channels.open = diagnosticsChannel.channel('undici:websocket:open') -channels.close = diagnosticsChannel.channel('undici:websocket:close') -channels.socketError = diagnosticsChannel.channel('undici:websocket:socket_error') - /** @type {import('crypto')} */ let crypto try { diff --git a/lib/websocket/receiver.js b/lib/websocket/receiver.js index bdd2031b418..512ef42a06b 100644 --- a/lib/websocket/receiver.js +++ b/lib/websocket/receiver.js @@ -1,9 +1,9 @@ 'use strict' const { Writable } = require('stream') -const diagnosticsChannel = require('diagnostics_channel') const { parserStates, opcodes, states, emptyBuffer } = require('./constants') const { kReadyState, kSentClose, kResponse, kReceivedClose } = require('./symbols') +const { channels } = require('../core/diagnostics') const { isValidStatusCode, failWebsocketConnection, websocketMessageReceived } = require('./util') const { WebsocketFrameSend } = require('./frame') @@ -12,10 +12,6 @@ const { WebsocketFrameSend } = require('./frame') // Copyright (c) 2013 Arnout Kazemier and contributors // Copyright (c) 2016 Luigi Pinca and contributors -const channels = {} -channels.ping = diagnosticsChannel.channel('undici:websocket:ping') -channels.pong = diagnosticsChannel.channel('undici:websocket:pong') - class ByteParser extends Writable { #buffers = [] #byteOffset = 0 diff --git a/package.json b/package.json index 17015f7b1b8..3d5f7ed20c5 100644 --- a/package.json +++ b/package.json @@ -80,9 +80,10 @@ "test:node-fetch": "mocha --exit test/node-fetch", "test:fetch": "npm run build:node && borp --expose-gc --coverage -p \"test/fetch/*.js\" && borp --coverage -p \"test/webidl/*.js\"", "test:jest": "jest", - "test:tap": "tap test/*.js test/diagnostics-channel/*.js", - "test:node-test": "borp --coverage -p \"test/node-test/*.js\"", - "test:tdd": "tap test/*.js test/diagnostics-channel/*.js -w", + "test:tap": "tap test/*.js", + "test:node-test": "borp --coverage -p \"test/node-test/**/*.js\"", + "test:tdd": "tap test/*.js --coverage -w", + "test:tdd:node-test": "borp -p \"test/node-test/**/*.js\" -w", "test:typescript": "tsd && tsc --skipLibCheck test/imports/undici-import.ts", "test:websocket": "borp --coverage -p \"test/websocket/*.js\"", "test:wpt": "node test/wpt/start-fetch.mjs && node test/wpt/start-FileAPI.mjs && node test/wpt/start-mimesniff.mjs && node test/wpt/start-xhr.mjs && node test/wpt/start-websockets.mjs", diff --git a/test/debug.js b/test/debug.js new file mode 100644 index 00000000000..61930e75843 --- /dev/null +++ b/test/debug.js @@ -0,0 +1,90 @@ +'use strict' + +const { test } = require('node:test') +const { spawn } = require('node:child_process') +const { tspl } = require('@matteo.collina/tspl') +const { join } = require('node:path') + +test('debug#websocket', async t => { + const assert = tspl(t, { plan: 5 }) + const child = spawn( + process.execPath, + [join(__dirname, 'fixtures/websocket.js')], + { + env: { + NODE_DEBUG: 'websocket' + } + } + ) + + t.after(() => { + child.kill() + }) + + child.stderr.setEncoding('utf8') + + for await (const chunk of child.stderr) { + if (chunk.includes('[UNDICI-WS] Warning')) { + continue + } + + assert.match( + chunk, + /(WEBSOCKET [0-9]+:) (connecting to|connected to|sending request|connection opened|closed connection)/ + ) + } +}) + +test('debug#fetch', async t => { + // Due to Node.js webpage redirect + const assert = tspl(t, { plan: 10 }) + const child = spawn( + process.execPath, + [join(__dirname, 'fixtures/fetch.js')], + { + env: { + NODE_DEBUG: 'fetch' + } + } + ) + + t.after(() => { + child.kill() + }) + + child.stderr.setEncoding('utf8') + + for await (const chunk of child.stderr) { + assert.match( + chunk, + /(FETCH [0-9]+:) (connecting to|connected to|sending request|received response|trailers received|request to)/ + ) + } +}) + +test('debug#undici', async t => { + // Due to Node.js webpage redirect + const assert = tspl(t, { plan: 10 }) + const child = spawn( + process.execPath, + [join(__dirname, 'fixtures/undici.js')], + { + env: { + NODE_DEBUG: 'undici' + } + } + ) + + t.after(() => { + child.kill() + }) + + child.stderr.setEncoding('utf8') + + for await (const chunk of child.stderr) { + assert.match( + chunk, + /(UNDICI [0-9]+:) (connecting to|connected to|sending request|received response|trailers received|request to)/ + ) + } +}) diff --git a/test/fixtures/fetch.js b/test/fixtures/fetch.js new file mode 100644 index 00000000000..ef2ea7b6e98 --- /dev/null +++ b/test/fixtures/fetch.js @@ -0,0 +1,6 @@ +const { fetch } = require('../..') + +fetch('https://nodejs.org').then( + res => res.body.cancel(), + () => {} +) diff --git a/test/fixtures/undici.js b/test/fixtures/undici.js new file mode 100644 index 00000000000..51aac6bf943 --- /dev/null +++ b/test/fixtures/undici.js @@ -0,0 +1,6 @@ +const { request } = require('../..') + +request('https://nodejs.org', { maxRedirections: 1 }).then( + res => res.body.dump(), + () => {} +) diff --git a/test/fixtures/websocket.js b/test/fixtures/websocket.js new file mode 100644 index 00000000000..ca8c83513fc --- /dev/null +++ b/test/fixtures/websocket.js @@ -0,0 +1,16 @@ +const { WebSocketServer } = require('ws') +const { WebSocket } = require('../..') + +const server = new WebSocketServer({ port: 0 }) + +server.on('connection', ws => { + ws.close(1000, 'goodbye') +}) + +const { port } = server.address() + +const ws = new WebSocket(`ws://localhost:${port}`, 'chat') + +ws.addEventListener('close', () => { + server.close() +}) diff --git a/test/diagnostics-channel/connect-error.js b/test/node-test/diagnostics-channel/connect-error.js similarity index 91% rename from test/diagnostics-channel/connect-error.js rename to test/node-test/diagnostics-channel/connect-error.js index a3bf2a45de7..1cc255c8d46 100644 --- a/test/diagnostics-channel/connect-error.js +++ b/test/node-test/diagnostics-channel/connect-error.js @@ -12,7 +12,7 @@ try { process.exit(0) } -const { Client } = require('../..') +const { Client } = require('../../..') test('Diagnostics channel - connect error', (t) => { const connectError = new Error('custom error') @@ -23,7 +23,7 @@ test('Diagnostics channel - connect error', (t) => { _connector = connector assert.equal(typeof _connector, 'function') - assert.equal(Object.keys(connectParams).length, 6) + assert.equal(Object.keys(connectParams).length, 7) const { host, hostname, protocol, port, servername } = connectParams @@ -35,7 +35,7 @@ test('Diagnostics channel - connect error', (t) => { }) diagnosticsChannel.channel('undici:client:connectError').subscribe(({ error, connectParams, connector }) => { - assert.equal(Object.keys(connectParams).length, 6) + assert.equal(Object.keys(connectParams).length, 7) assert.equal(_connector, connector) const { host, hostname, protocol, port, servername } = connectParams diff --git a/test/diagnostics-channel/error.js b/test/node-test/diagnostics-channel/error.js similarity index 97% rename from test/diagnostics-channel/error.js rename to test/node-test/diagnostics-channel/error.js index 2a737d70b33..9b320b59824 100644 --- a/test/diagnostics-channel/error.js +++ b/test/node-test/diagnostics-channel/error.js @@ -12,7 +12,7 @@ try { process.exit(0) } -const { Client } = require('../..') +const { Client } = require('../../..') const { createServer } = require('http') test('Diagnostics channel - error', (t) => { diff --git a/test/diagnostics-channel/get.js b/test/node-test/diagnostics-channel/get.js similarity index 96% rename from test/diagnostics-channel/get.js rename to test/node-test/diagnostics-channel/get.js index e0feeb2fe56..a41df9d2563 100644 --- a/test/diagnostics-channel/get.js +++ b/test/node-test/diagnostics-channel/get.js @@ -12,7 +12,7 @@ try { process.exit(0) } -const { Client } = require('../..') +const { Client } = require('../../..') const { createServer } = require('http') test('Diagnostics channel - get', (t) => { @@ -51,7 +51,7 @@ test('Diagnostics channel - get', (t) => { _connector = connector assert.equal(typeof _connector, 'function') - assert.equal(Object.keys(connectParams).length, 6) + assert.equal(Object.keys(connectParams).length, 7) const { host, hostname, protocol, port, servername } = connectParams @@ -67,7 +67,7 @@ test('Diagnostics channel - get', (t) => { _socket = socket assert.equal(_connector, connector) - assert.equal(Object.keys(connectParams).length, 6) + assert.equal(Object.keys(connectParams).length, 7) const { host, hostname, protocol, port, servername } = connectParams diff --git a/test/diagnostics-channel/post-stream.js b/test/node-test/diagnostics-channel/post-stream.js similarity index 96% rename from test/diagnostics-channel/post-stream.js rename to test/node-test/diagnostics-channel/post-stream.js index 3510e74993b..aa2792a2732 100644 --- a/test/diagnostics-channel/post-stream.js +++ b/test/node-test/diagnostics-channel/post-stream.js @@ -13,7 +13,7 @@ try { process.exit(0) } -const { Client } = require('../..') +const { Client } = require('../../..') const { createServer } = require('http') test('Diagnostics channel - post stream', (t) => { @@ -53,7 +53,7 @@ test('Diagnostics channel - post stream', (t) => { _connector = connector assert.equal(typeof _connector, 'function') - assert.equal(Object.keys(connectParams).length, 6) + assert.equal(Object.keys(connectParams).length, 7) const { host, hostname, protocol, port, servername } = connectParams @@ -68,7 +68,7 @@ test('Diagnostics channel - post stream', (t) => { diagnosticsChannel.channel('undici:client:connected').subscribe(({ connectParams, socket, connector }) => { _socket = socket - assert.equal(Object.keys(connectParams).length, 6) + assert.equal(Object.keys(connectParams).length, 7) assert.equal(_connector, connector) const { host, hostname, protocol, port, servername } = connectParams diff --git a/test/diagnostics-channel/post.js b/test/node-test/diagnostics-channel/post.js similarity index 96% rename from test/diagnostics-channel/post.js rename to test/node-test/diagnostics-channel/post.js index 30203a7e7c7..427853b66ea 100644 --- a/test/diagnostics-channel/post.js +++ b/test/node-test/diagnostics-channel/post.js @@ -12,7 +12,7 @@ try { process.exit(0) } -const { Client } = require('../..') +const { Client } = require('../../../') const { createServer } = require('http') test('Diagnostics channel - post', (t) => { @@ -51,7 +51,7 @@ test('Diagnostics channel - post', (t) => { _connector = connector assert.equal(typeof _connector, 'function') - assert.equal(Object.keys(connectParams).length, 6) + assert.equal(Object.keys(connectParams).length, 7) const { host, hostname, protocol, port, servername } = connectParams @@ -66,7 +66,7 @@ test('Diagnostics channel - post', (t) => { diagnosticsChannel.channel('undici:client:connected').subscribe(({ connectParams, socket, connector }) => { _socket = socket - assert.equal(Object.keys(connectParams).length, 6) + assert.equal(Object.keys(connectParams).length, 7) assert.equal(_connector, connector) const { host, hostname, protocol, port, servername } = connectParams