diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-21 20:56:19 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-21 20:56:19 +0000 |
commit | 0b6210cd37b68b94252cb798598b12974a20e1c1 (patch) | |
tree | e371686554a877842d95aa94f100bee552ff2a8e /test/diagnostics-channel/error.js | |
parent | Initial commit. (diff) | |
download | node-undici-0b6210cd37b68b94252cb798598b12974a20e1c1.tar.xz node-undici-0b6210cd37b68b94252cb798598b12974a20e1c1.zip |
Adding upstream version 5.28.2+dfsg1+~cs23.11.12.3.upstream/5.28.2+dfsg1+_cs23.11.12.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/diagnostics-channel/error.js')
-rw-r--r-- | test/diagnostics-channel/error.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/diagnostics-channel/error.js b/test/diagnostics-channel/error.js new file mode 100644 index 0000000..1f350b1 --- /dev/null +++ b/test/diagnostics-channel/error.js @@ -0,0 +1,52 @@ +'use strict' + +const t = require('tap') + +let diagnosticsChannel + +try { + diagnosticsChannel = require('diagnostics_channel') +} catch { + t.skip('missing diagnostics_channel') + process.exit(0) +} + +const { Client } = require('../..') +const { createServer } = require('http') + +t.plan(3) + +const server = createServer((req, res) => { + res.destroy() +}) +t.teardown(server.close.bind(server)) + +const reqHeaders = { + foo: undefined, + bar: 'bar' +} + +let _req +diagnosticsChannel.channel('undici:request:create').subscribe(({ request }) => { + _req = request +}) + +diagnosticsChannel.channel('undici:request:error').subscribe(({ request, error }) => { + t.equal(_req, request) + t.equal(error.code, 'UND_ERR_SOCKET') +}) + +server.listen(0, () => { + const client = new Client(`http://localhost:${server.address().port}`, { + keepAliveTimeout: 300e3 + }) + t.teardown(client.close.bind(client)) + + client.request({ + path: '/', + method: 'GET', + headers: reqHeaders + }, (err, data) => { + t.equal(err.code, 'UND_ERR_SOCKET') + }) +}) |