-
-
Notifications
You must be signed in to change notification settings - Fork 715
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug Description
throwOnError does not work on HTTPParserError.
Reproducible By
const { request } = require('undici');
process.on('uncaughtException', err => console.error('uncaught exception:', err));
process.on('unhandledRejection', err => console.error('unhandled rejection:', err));
request('http://www.rolbox.it/rk-kastelruth/webcam/web03.jpg', { throwOnError: true })
.then(() => console.log('then called'))
.catch(e => console.error('catch called:', e))
.finally(() => console.log('finally called'));output:
unhandled rejection: HTTPParserError: Response does not match the HTTP/1.1 protocol (Invalid character in chunk size)
at Parser.execute (/private/tmp/undici-test/node_modules/undici/lib/dispatcher/client-h1.js:277:15)
at Parser.readMore (/private/tmp/undici-test/node_modules/undici/lib/dispatcher/client-h1.js:218:12)
at Socket.<anonymous> (/private/tmp/undici-test/node_modules/undici/lib/dispatcher/client-h1.js:669:14)
at Socket.emit (node:events:518:28)
at emitReadable_ (node:internal/streams/readable:832:12)
at process.processTicksAndRejections (node:internal/process/task_queues:81:21) {
code: 'HPE_INVALID_CHUNK_SIZE',
data: ' \r\n' +
'<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n' +
'<HTML><HEAD>\n' +
'<TITLE>404 Not Found</TITLE>\n' +
'</HEAD><BODY>\n' +
'<H1>Not Found</H1>\n' +
'The requested URL /rk-kastelruth/webcam/web03.jpg was not found on this server.<P>\n' +
'</BODY></HTML>\n' +
'\r\n' +
'0\r\n' +
'\r\n'
}
Expected Behavior
I would expect the HTTPParserError to be caught in catch and not to get unhandled rejection.
Environment
Node v20.12.2
Additional context
The behavior with throwOnError: false is also weird.
const { request } = require('undici');
process.on('uncaughtException', err => console.error('uncaught exception:', err));
process.on('unhandledRejection', err => console.error('unhandled rejection:', err));
request('http://www.rolbox.it/rk-kastelruth/webcam/web03.jpg', { throwOnError: false })
.then(() => console.log('then called'))
.catch(e => console.error('catch called:', e))
.finally(() => console.log('finally called'));output:
then called
finally called
uncaught exception: HTTPParserError: Response does not match the HTTP/1.1 protocol (Invalid character in chunk size)
at Parser.execute (/private/tmp/undici-test/node_modules/undici/lib/dispatcher/client-h1.js:277:15)
at Parser.readMore (/private/tmp/undici-test/node_modules/undici/lib/dispatcher/client-h1.js:218:12)
at Socket.<anonymous> (/private/tmp/undici-test/node_modules/undici/lib/dispatcher/client-h1.js:669:14)
at Socket.emit (node:events:518:28)
at emitReadable_ (node:internal/streams/readable:832:12)
at process.processTicksAndRejections (node:internal/process/task_queues:81:21) {
code: 'HPE_INVALID_CHUNK_SIZE',
data: ' \r\n' +
'<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n' +
'<HTML><HEAD>\n' +
'<TITLE>404 Not Found</TITLE>\n' +
'</HEAD><BODY>\n' +
'<H1>Not Found</H1>\n' +
'The requested URL /rk-kastelruth/webcam/web03.jpg was not found on this server.<P>\n' +
'</BODY></HTML>\n' +
'\r\n' +
'0\r\n' +
'\r\n'
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working