You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Option to throw on error status codes (nodejs#1453)
* Improve coverage
* Update TS types
* Fix linting
* Improve naming, add type tests
* Address code review comments
* make check explicit
Co-authored-by: Robert Nagy <[email protected]>
* make condition more explicit
Co-authored-by: Robert Nagy <[email protected]>
Co-authored-by: Robert Nagy <[email protected]>
Copy file name to clipboardExpand all lines: docs/api/Dispatcher.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -200,13 +200,14 @@ Returns: `Boolean` - `false` if dispatcher is busy and further dispatch calls wo
200
200
***upgrade**`string | null` (optional) - Default: `null` - Upgrade the request. Should be used to specify the kind of upgrade i.e. `'Websocket'`.
201
201
***bodyTimeout**`number | null` (optional) - The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Defaults to 30 seconds.
202
202
***headersTimeout**`number | null` (optional) - The amount of time the parser will wait to receive the complete HTTP headers. Defaults to 30 seconds.
203
+
***throwOnError**`boolean` (optional) - Default: `false` - Whether Undici should throw an error upon receiving a 4xx or 5xx response from the server.
203
204
204
205
#### Parameter: `DispatchHandler`
205
206
206
207
***onConnect**`(abort: () => void, context: object) => void` - Invoked before request is dispatched on socket. May be invoked multiple times when a request is retried when the request at the head of the pipeline fails.
207
208
***onError**`(error: Error) => void` - Invoked when an error has occurred. May not throw.
208
209
***onUpgrade**`(statusCode: number, headers: Buffer[], socket: Duplex) => void` (optional) - Invoked when request is upgraded. Required if `DispatchOptions.upgrade` is defined or `DispatchOptions.method === 'CONNECT'`.
209
-
***onHeaders**`(statusCode: number, headers: Buffer[], resume: () => void) => boolean` - Invoked when statusCode and headers have been received. May be invoked multiple times due to 1xx informational headers. Not required for `upgrade` requests.
210
+
***onHeaders**`(statusCode: number, headers: Buffer[], resume: () => void, statusText: string) => boolean` - Invoked when statusCode and headers have been received. May be invoked multiple times due to 1xx informational headers. Not required for `upgrade` requests.
210
211
***onData**`(chunk: Buffer) => boolean` - Invoked when response payload data is received. Not required for `upgrade` requests.
211
212
***onComplete**`(trailers: Buffer[]) => void` - Invoked when response payload and trailers have been received and the request has completed. Not required for `upgrade` requests.
212
213
***onBodySent**`(chunk: string | Buffer | Uint8Array) => void` - Invoked when a body chunk is sent to the server. Not required. For a stream or iterable body this will be invoked for every chunk. For other body types, it will be invoked once after the body is sent.
Copy file name to clipboardExpand all lines: types/dispatcher.d.ts
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -57,6 +57,8 @@ declare namespace Dispatcher {
57
57
headersTimeout?: number|null;
58
58
/** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use 0 to disable it entirely. Defaults to 30 seconds. */
59
59
bodyTimeout?: number|null;
60
+
/** Whether Undici should throw an error upon receiving a 4xx or 5xx response from the server. Defaults to false */
0 commit comments