@noodleseed/one 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/author-loop.d.ts.map +1 -1
- package/dist/commands/author-loop.js +2 -2
- package/dist/commands/author-loop.js.map +1 -1
- package/dist/commands/catalog-dispatch.d.ts.map +1 -1
- package/dist/commands/catalog-dispatch.js +21 -2
- package/dist/commands/catalog-dispatch.js.map +1 -1
- package/dist/commands/deploy-ops.d.ts.map +1 -1
- package/dist/commands/deploy-ops.js +28 -11
- package/dist/commands/deploy-ops.js.map +1 -1
- package/dist/first-run.d.ts +11 -0
- package/dist/first-run.d.ts.map +1 -1
- package/dist/first-run.js +19 -4
- package/dist/first-run.js.map +1 -1
- package/dist/project-scaffold-templates.d.ts +11 -0
- package/dist/project-scaffold-templates.d.ts.map +1 -0
- package/dist/project-scaffold-templates.js +359 -0
- package/dist/project-scaffold-templates.js.map +1 -0
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +1 -323
- package/dist/project.js.map +1 -1
- package/dist/react.d.ts +2 -2
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/dist/validate.d.ts +12 -0
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +11 -0
- package/dist/validate.js.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/skill-content.d.ts.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/skill-content.js +6 -9
- package/node_modules/@noodle-borg/agent-kit/dist/skill-content.js.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/package.json +1 -1
- package/node_modules/@noodle-borg/authoring/dist/index.d.ts +3 -3
- package/node_modules/@noodle-borg/authoring/dist/index.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/index.js +1 -1
- package/node_modules/@noodle-borg/authoring/dist/index.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/components.d.ts +302 -7
- package/node_modules/@noodle-borg/authoring/dist/react/components.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/components.js +39 -7
- package/node_modules/@noodle-borg/authoring/dist/react/components.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/index.d.ts +4 -2
- package/node_modules/@noodle-borg/authoring/dist/react/index.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/index.js +2 -1
- package/node_modules/@noodle-borg/authoring/dist/react/index.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.d.ts +2618 -0
- package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.d.ts.map +1 -0
- package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.js +110 -0
- package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.js.map +1 -0
- package/node_modules/@noodle-borg/authoring/dist/react.d.ts +2 -2
- package/node_modules/@noodle-borg/authoring/dist/react.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react.js +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/recording.d.ts +1 -1
- package/node_modules/@noodle-borg/authoring/dist/recording.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/recording.js +14 -1
- package/node_modules/@noodle-borg/authoring/dist/recording.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/server.d.ts +25 -2
- package/node_modules/@noodle-borg/authoring/dist/server.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/server.js +7 -3
- package/node_modules/@noodle-borg/authoring/dist/server.js.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/compile.d.ts.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/compile.js +20 -8
- package/node_modules/@noodle-borg/compiler/dist/compile.js.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.d.ts +2 -0
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.d.ts.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.js +6 -0
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.js.map +1 -1
- package/node_modules/@noodle-borg/connector-http/package.json +1 -1
- package/node_modules/@noodle-borg/protocol/dist/mapping.d.ts.map +1 -1
- package/node_modules/@noodle-borg/protocol/dist/mapping.js +8 -0
- package/node_modules/@noodle-borg/protocol/dist/mapping.js.map +1 -1
- package/node_modules/hono/dist/adapter/aws-lambda/handler.js +15 -21
- package/node_modules/hono/dist/adapter/bun/websocket.js +3 -1
- package/node_modules/hono/dist/adapter/lambda-edge/handler.js +8 -2
- package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +15 -21
- package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +3 -1
- package/node_modules/hono/dist/cjs/adapter/lambda-edge/handler.js +8 -2
- package/node_modules/hono/dist/cjs/helper/css/common.js +3 -1
- package/node_modules/hono/dist/cjs/helper/css/index.js +9 -1
- package/node_modules/hono/dist/cjs/jsx/base.js +8 -14
- package/node_modules/hono/dist/cjs/jsx/components.js +41 -21
- package/node_modules/hono/dist/cjs/jsx/context.js +131 -5
- package/node_modules/hono/dist/cjs/jsx/streaming.js +9 -7
- package/node_modules/hono/dist/cjs/middleware/cors/index.js +2 -5
- package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +2 -2
- package/node_modules/hono/dist/cjs/utils/body.js +12 -4
- package/node_modules/hono/dist/cjs/utils/buffer.js +2 -1
- package/node_modules/hono/dist/cjs/validator/validator.js +3 -3
- package/node_modules/hono/dist/helper/css/common.js +3 -1
- package/node_modules/hono/dist/helper/css/index.js +9 -1
- package/node_modules/hono/dist/jsx/base.js +15 -15
- package/node_modules/hono/dist/jsx/components.js +42 -22
- package/node_modules/hono/dist/jsx/context.js +129 -5
- package/node_modules/hono/dist/jsx/streaming.js +10 -8
- package/node_modules/hono/dist/middleware/cors/index.js +2 -5
- package/node_modules/hono/dist/middleware/serve-static/index.js +2 -2
- package/node_modules/hono/dist/types/adapter/aws-lambda/handler.d.ts +1 -1
- package/node_modules/hono/dist/types/jsx/base.d.ts +1 -3
- package/node_modules/hono/dist/types/jsx/context.d.ts +39 -0
- package/node_modules/hono/dist/types/middleware/context-storage/index.d.ts +2 -2
- package/node_modules/hono/dist/types/utils/body.d.ts +1 -1
- package/node_modules/hono/dist/utils/body.js +12 -4
- package/node_modules/hono/dist/utils/buffer.js +2 -1
- package/node_modules/hono/dist/validator/validator.js +3 -3
- package/node_modules/hono/package.json +9 -10
- package/node_modules/tailwindcss/dist/chunk-HMCCH6MG.mjs +1 -0
- package/node_modules/tailwindcss/dist/default-theme.mjs +1 -1
- package/node_modules/tailwindcss/dist/lib.js +13 -13
- package/node_modules/tailwindcss/dist/lib.mjs +18 -18
- package/node_modules/tailwindcss/package.json +2 -2
- package/node_modules/undici/README.md +3 -2
- package/node_modules/undici/docs/docs/api/Agent.md +248 -44
- package/node_modules/undici/docs/docs/api/BalancedPool.md +246 -48
- package/node_modules/undici/docs/docs/api/CacheStorage.md +171 -13
- package/node_modules/undici/docs/docs/api/CacheStore.md +294 -98
- package/node_modules/undici/docs/docs/api/Client.md +365 -178
- package/node_modules/undici/docs/docs/api/ClientStats.md +80 -14
- package/node_modules/undici/docs/docs/api/Connector.md +118 -36
- package/node_modules/undici/docs/docs/api/ContentType.md +65 -25
- package/node_modules/undici/docs/docs/api/Cookies.md +125 -47
- package/node_modules/undici/docs/docs/api/Debug.md +34 -18
- package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +364 -164
- package/node_modules/undici/docs/docs/api/Dispatcher.md +479 -1093
- package/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +101 -87
- package/node_modules/undici/docs/docs/api/Errors.md +503 -40
- package/node_modules/undici/docs/docs/api/EventSource.md +294 -32
- package/node_modules/undici/docs/docs/api/Fetch.md +680 -31
- package/node_modules/undici/docs/docs/api/GlobalInstallation.md +78 -98
- package/node_modules/undici/docs/docs/api/H2CClient.md +298 -176
- package/node_modules/undici/docs/docs/api/Interceptors.md +355 -0
- package/node_modules/undici/docs/docs/api/MockAgent.md +314 -322
- package/node_modules/undici/docs/docs/api/MockCallHistory.md +272 -98
- package/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +189 -26
- package/node_modules/undici/docs/docs/api/MockClient.md +151 -33
- package/node_modules/undici/docs/docs/api/MockErrors.md +56 -5
- package/node_modules/undici/docs/docs/api/MockPool.md +299 -263
- package/node_modules/undici/docs/docs/api/Pool.md +235 -43
- package/node_modules/undici/docs/docs/api/PoolStats.md +119 -13
- package/node_modules/undici/docs/docs/api/ProxyAgent.md +179 -160
- package/node_modules/undici/docs/docs/api/RedirectHandler.md +238 -63
- package/node_modules/undici/docs/docs/api/RetryAgent.md +113 -26
- package/node_modules/undici/docs/docs/api/RetryHandler.md +161 -77
- package/node_modules/undici/docs/docs/api/RoundRobinPool.md +166 -72
- package/node_modules/undici/docs/docs/api/SnapshotAgent.md +264 -542
- package/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +162 -186
- package/node_modules/undici/docs/docs/api/Util.md +68 -11
- package/node_modules/undici/docs/docs/api/WebSocket.md +475 -80
- package/node_modules/undici/docs/docs/api/api-lifecycle.md +100 -32
- package/node_modules/undici/docs/docs/best-practices/client-certificate.md +2 -0
- package/node_modules/undici/docs/docs/best-practices/crawling.md +3 -1
- package/node_modules/undici/docs/docs/best-practices/migrating-from-v7-to-v8.md +6 -4
- package/node_modules/undici/docs/docs/best-practices/mocking-request.md +9 -7
- package/node_modules/undici/docs/docs/best-practices/proxy.md +3 -1
- package/node_modules/undici/docs/docs/best-practices/undici-vs-builtin-fetch.md +10 -8
- package/node_modules/undici/docs/docs/best-practices/writing-tests.md +2 -0
- package/node_modules/undici/docs/docs/{GettingStarted.md → getting-started.md} +22 -19
- package/node_modules/undici/docs/docs/index.md +779 -0
- package/node_modules/undici/docs/docs/site.json +125 -0
- package/node_modules/undici/docs/docs/type-map.json +79 -0
- package/node_modules/undici/lib/api/api-request.js +7 -1
- package/node_modules/undici/lib/api/readable.js +47 -2
- package/node_modules/undici/lib/core/errors.js +20 -0
- package/node_modules/undici/lib/core/request.js +1 -1
- package/node_modules/undici/lib/core/util.js +24 -1
- package/node_modules/undici/lib/dispatcher/client-h1.js +92 -1
- package/node_modules/undici/lib/dispatcher/client-h2.js +322 -118
- package/node_modules/undici/lib/dispatcher/client.js +6 -2
- package/node_modules/undici/lib/dispatcher/dispatcher-base.js +1 -0
- package/node_modules/undici/lib/dispatcher/proxy-agent.js +42 -7
- package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +4 -2
- package/node_modules/undici/lib/handler/redirect-handler.js +1 -0
- package/node_modules/undici/lib/handler/retry-handler.js +57 -19
- package/node_modules/undici/lib/util/cache.js +8 -2
- package/node_modules/undici/lib/web/cookies/parse.js +20 -27
- package/node_modules/undici/lib/web/cookies/util.js +1 -1
- package/node_modules/undici/lib/web/eventsource/eventsource.js +7 -18
- package/node_modules/undici/lib/web/eventsource/util.js +32 -1
- package/node_modules/undici/lib/web/fetch/body.js +43 -0
- package/node_modules/undici/lib/web/fetch/constants.js +1 -1
- package/node_modules/undici/lib/web/fetch/index.js +11 -2
- package/node_modules/undici/lib/web/fetch/request.js +1 -0
- package/node_modules/undici/lib/web/fetch/util.js +4 -1
- package/node_modules/undici/lib/web/websocket/receiver.js +20 -3
- package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +8 -1
- package/node_modules/undici/lib/web/websocket/websocket.js +3 -1
- package/node_modules/undici/package.json +1 -1
- package/node_modules/undici/types/client.d.ts +6 -1
- package/node_modules/undici/types/cookies.d.ts +1 -1
- package/node_modules/undici/types/errors.d.ts +10 -0
- package/node_modules/undici/types/fetch.d.ts +1 -0
- package/node_modules/undici/types/handlers.d.ts +2 -0
- package/node_modules/undici/types/proxy-agent.d.ts +7 -0
- package/package.json +4 -4
- package/react/styles.css +510 -5
- package/react/styles.source.css +850 -0
- package/node_modules/hono/dist/tsconfig.build.tsbuildinfo +0 -1
- package/node_modules/tailwindcss/dist/chunk-XVOTX5KS.mjs +0 -1
|
@@ -1,101 +1,276 @@
|
|
|
1
|
-
#
|
|
1
|
+
# RedirectHandler
|
|
2
|
+
|
|
3
|
+
<!--introduced_in=v4.0.0-->
|
|
4
|
+
<!--type=module-->
|
|
5
|
+
<!-- source_link=lib/handler/redirect-handler.js -->
|
|
6
|
+
|
|
7
|
+
> Stability: 2 - Stable
|
|
8
|
+
|
|
9
|
+
A dispatch handler that follows HTTP redirects on behalf of another handler. It
|
|
10
|
+
wraps a downstream `handler` and a `dispatch` function: when a redirectable
|
|
11
|
+
response is received it transparently re-dispatches the request to the new
|
|
12
|
+
location, forwarding the lifecycle callbacks to the wrapped `handler` only once a
|
|
13
|
+
final (non-redirect) response is reached.
|
|
14
|
+
|
|
15
|
+
Redirects are followed for the `300`, `301`, `302`, `303`, `307`, and `308`
|
|
16
|
+
status codes, up to `maxRedirections` hops. Following the relevant HTTP
|
|
17
|
+
specifications, the method is downgraded to `GET` for `301`/`302` `POST`
|
|
18
|
+
responses and for `303` responses with any method other than `HEAD`, request
|
|
19
|
+
bodies that have already been consumed are not replayed, and headers that refer
|
|
20
|
+
to the original URL (such as `host`) are stripped on each hop, with additional
|
|
21
|
+
credential headers removed on cross-origin redirects.
|
|
22
|
+
|
|
23
|
+
```mjs
|
|
24
|
+
import { RedirectHandler } from 'undici'
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```cjs
|
|
28
|
+
const { RedirectHandler } = require('undici')
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Most users do not construct `RedirectHandler` directly. The `maxRedirections`
|
|
32
|
+
option on [`Dispatcher`][] methods and the higher-level clients use it
|
|
33
|
+
internally.
|
|
34
|
+
|
|
35
|
+
## Class: `RedirectHandler`
|
|
36
|
+
|
|
37
|
+
<!-- YAML
|
|
38
|
+
added: v4.0.0
|
|
39
|
+
-->
|
|
40
|
+
|
|
41
|
+
* Extends: {DispatchHandler}
|
|
42
|
+
|
|
43
|
+
Implements the [`DispatchHandler`][] interface, delegating every callback to the
|
|
44
|
+
wrapped `handler` while intercepting redirect responses.
|
|
45
|
+
|
|
46
|
+
### `new RedirectHandler(dispatch, maxRedirections, opts, handler)`
|
|
47
|
+
|
|
48
|
+
<!-- YAML
|
|
49
|
+
added: v4.0.0
|
|
50
|
+
-->
|
|
51
|
+
|
|
52
|
+
* `dispatch` {Function} The dispatch function used to issue the original request
|
|
53
|
+
and every subsequent redirect. Called as `dispatch(options, handler)`.
|
|
54
|
+
* `maxRedirections` {number|null} The maximum number of redirects to follow. Must
|
|
55
|
+
be a non-negative integer or `null`. When `null` or `0`, no redirects are
|
|
56
|
+
followed and redirect responses are passed through to the wrapped `handler`.
|
|
57
|
+
* `opts` {DispatchOptions} The dispatch options for the request. In addition to
|
|
58
|
+
the standard dispatch options, the following redirect-specific fields are
|
|
59
|
+
recognized:
|
|
60
|
+
* `throwOnMaxRedirect` {boolean} When `true`, an error is thrown once
|
|
61
|
+
`maxRedirections` is reached instead of returning the last redirect response.
|
|
62
|
+
**Default:** `false`.
|
|
63
|
+
* `stripHeadersOnRedirect` {string[]} Header names to remove from the request on
|
|
64
|
+
every redirect hop. **Default:** `null`.
|
|
65
|
+
* `stripHeadersOnCrossOriginRedirect` {string[]} Additional header names to
|
|
66
|
+
remove from the request when a redirect points to a different origin.
|
|
67
|
+
**Default:** `null`.
|
|
68
|
+
* `handler` {DispatchHandler} The downstream handler that receives the lifecycle
|
|
69
|
+
callbacks for the final response.
|
|
70
|
+
|
|
71
|
+
Throws an [`InvalidArgumentError`][] when `maxRedirections` is not a non-negative
|
|
72
|
+
integer, when `throwOnMaxRedirect` is not a boolean, or when either
|
|
73
|
+
`stripHeadersOnRedirect` or `stripHeadersOnCrossOriginRedirect` is not an array of
|
|
74
|
+
header-name strings.
|
|
75
|
+
|
|
76
|
+
```mjs
|
|
77
|
+
import { Client, RedirectHandler } from 'undici'
|
|
78
|
+
|
|
79
|
+
const client = new Client('http://example.com')
|
|
80
|
+
const dispatch = client.dispatch.bind(client)
|
|
81
|
+
|
|
82
|
+
const handler = new RedirectHandler(dispatch, 5, {
|
|
83
|
+
method: 'GET',
|
|
84
|
+
path: '/',
|
|
85
|
+
origin: 'http://example.com',
|
|
86
|
+
}, {
|
|
87
|
+
onRequestStart () {},
|
|
88
|
+
onResponseStart (controller, statusCode, headers) {
|
|
89
|
+
console.log(statusCode)
|
|
90
|
+
},
|
|
91
|
+
onResponseData (controller, chunk) {},
|
|
92
|
+
onResponseEnd () {},
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
dispatch({ method: 'GET', path: '/', origin: 'http://example.com' }, handler)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Static method: `RedirectHandler.buildDispatch(dispatcher, maxRedirections)`
|
|
99
|
+
|
|
100
|
+
<!-- YAML
|
|
101
|
+
added: v7.0.0
|
|
102
|
+
-->
|
|
103
|
+
|
|
104
|
+
* `dispatcher` {Dispatcher} The dispatcher whose `dispatch` method is wrapped.
|
|
105
|
+
* `maxRedirections` {number|null} The maximum number of redirects to follow. Must
|
|
106
|
+
be a non-negative integer or `null`.
|
|
107
|
+
* Returns: {Function} A `dispatch(options, handler)` function that wraps each call
|
|
108
|
+
in a `RedirectHandler` before delegating to `dispatcher`.
|
|
109
|
+
|
|
110
|
+
Builds a redirect-aware dispatch function from an existing dispatcher. The
|
|
111
|
+
returned function has the same shape as `dispatcher.dispatch` but follows
|
|
112
|
+
redirects automatically. Throws an [`InvalidArgumentError`][] when
|
|
113
|
+
`maxRedirections` is not a non-negative integer.
|
|
114
|
+
|
|
115
|
+
```mjs
|
|
116
|
+
import { Client, RedirectHandler } from 'undici'
|
|
117
|
+
|
|
118
|
+
const client = new Client('http://example.com')
|
|
119
|
+
const dispatch = RedirectHandler.buildDispatch(client, 5)
|
|
2
120
|
|
|
3
|
-
|
|
121
|
+
dispatch({ method: 'GET', path: '/', origin: 'http://example.com' }, {
|
|
122
|
+
onRequestStart () {},
|
|
123
|
+
onResponseStart (controller, statusCode) {
|
|
124
|
+
console.log(statusCode)
|
|
125
|
+
},
|
|
126
|
+
onResponseData () {},
|
|
127
|
+
onResponseEnd () {},
|
|
128
|
+
})
|
|
129
|
+
```
|
|
4
130
|
|
|
5
|
-
|
|
131
|
+
### `redirectHandler.onRequestStart(controller, context)`
|
|
6
132
|
|
|
7
|
-
|
|
133
|
+
<!-- YAML
|
|
134
|
+
added: v7.0.0
|
|
135
|
+
-->
|
|
8
136
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
- **opts** `object` - Options for handling redirection. Supports `throwOnMaxRedirect`, `stripHeadersOnRedirect`, and `stripHeadersOnCrossOriginRedirect`.
|
|
12
|
-
- **handler** `object` - An object containing handlers for different stages of the request lifecycle.
|
|
137
|
+
* `controller` {DispatchController} The controller for the in-flight request.
|
|
138
|
+
* `context` {Object} The dispatch context.
|
|
13
139
|
|
|
14
|
-
|
|
140
|
+
Forwards the request-start event to the wrapped `handler`, augmenting `context`
|
|
141
|
+
with the current redirect `history`.
|
|
15
142
|
|
|
16
|
-
###
|
|
143
|
+
### `redirectHandler.onRequestUpgrade(controller, statusCode, headers, socket)`
|
|
17
144
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
- **throwOnMaxRedirect** `boolean` - Throw when the maximum number of redirections is reached.
|
|
22
|
-
- **stripHeadersOnRedirect** `string[]` - Header names to remove from all redirected requests.
|
|
23
|
-
- **stripHeadersOnCrossOriginRedirect** `string[]` - Header names to remove from cross-origin redirected requests.
|
|
24
|
-
- **handler** `object` (required) - Handlers for different stages of the request lifecycle.
|
|
145
|
+
<!-- YAML
|
|
146
|
+
added: v7.0.0
|
|
147
|
+
-->
|
|
25
148
|
|
|
26
|
-
|
|
149
|
+
* `controller` {DispatchController} The controller for the in-flight request.
|
|
150
|
+
* `statusCode` {number} The HTTP status code of the upgrade response.
|
|
151
|
+
* `headers` {Object} The response headers.
|
|
152
|
+
* `socket` {Duplex} The upgraded socket.
|
|
27
153
|
|
|
28
|
-
|
|
29
|
-
- **abort** `function` - The abort function.
|
|
30
|
-
- **opts** `object` - The options for handling redirection.
|
|
31
|
-
- **maxRedirections** `number` - Maximum number of redirections allowed.
|
|
32
|
-
- **handler** `object` - Handlers for different stages of the request lifecycle.
|
|
33
|
-
- **history** `Array` - An array representing the history of URLs during redirection.
|
|
154
|
+
Forwards a connection upgrade to the wrapped `handler`.
|
|
34
155
|
|
|
35
|
-
###
|
|
156
|
+
### `redirectHandler.onResponseStart(controller, statusCode, headers, statusMessage)`
|
|
36
157
|
|
|
37
|
-
|
|
158
|
+
<!-- YAML
|
|
159
|
+
added: v7.0.0
|
|
160
|
+
-->
|
|
38
161
|
|
|
39
|
-
|
|
162
|
+
* `controller` {DispatchController} The controller for the in-flight request.
|
|
163
|
+
* `statusCode` {number} The HTTP status code of the response.
|
|
164
|
+
* `headers` {Object} The response headers.
|
|
165
|
+
* `statusMessage` {string} The HTTP status message.
|
|
40
166
|
|
|
41
|
-
|
|
167
|
+
Inspects the response headers to decide whether to follow a redirect. When the
|
|
168
|
+
status code is redirectable, the `maxRedirections` limit has not been reached, and
|
|
169
|
+
the request body has not been consumed, the `location` property is set, the method
|
|
170
|
+
and headers are adjusted for the next hop, and the response is not forwarded.
|
|
171
|
+
Otherwise the event is forwarded to the wrapped `handler`.
|
|
42
172
|
|
|
43
|
-
|
|
44
|
-
|
|
173
|
+
Throws when `throwOnMaxRedirect` is `true` and the number of recorded redirects
|
|
174
|
+
has reached `maxRedirections`, and throws an [`InvalidArgumentError`][] if a
|
|
175
|
+
redirect loop is detected (for example when a [`Client`][] or [`Pool`][] is used
|
|
176
|
+
for a cross-origin redirect; use an [`Agent`][] instead).
|
|
45
177
|
|
|
46
|
-
|
|
178
|
+
### `redirectHandler.onResponseData(controller, chunk)`
|
|
47
179
|
|
|
48
|
-
|
|
180
|
+
<!-- YAML
|
|
181
|
+
added: v7.0.0
|
|
182
|
+
-->
|
|
49
183
|
|
|
50
|
-
|
|
184
|
+
* `controller` {DispatchController} The controller for the in-flight request.
|
|
185
|
+
* `chunk` {Buffer} A chunk of the response body.
|
|
51
186
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
- **headers** `object` - The headers received in the response.
|
|
55
|
-
- **socket** `object` - The socket object.
|
|
187
|
+
Forwards body data to the wrapped `handler`. While a redirect is pending
|
|
188
|
+
(`location` is set), the `3xx` response body is ignored.
|
|
56
189
|
|
|
57
|
-
|
|
190
|
+
### `redirectHandler.onResponseEnd(controller, trailers)`
|
|
58
191
|
|
|
59
|
-
|
|
192
|
+
<!-- YAML
|
|
193
|
+
added: v7.0.0
|
|
194
|
+
-->
|
|
60
195
|
|
|
61
|
-
|
|
196
|
+
* `controller` {DispatchController} The controller for the in-flight request.
|
|
197
|
+
* `trailers` {Object} The response trailers.
|
|
62
198
|
|
|
63
|
-
|
|
64
|
-
|
|
199
|
+
Completes the response. When a redirect is pending, the request is re-dispatched
|
|
200
|
+
to the new `location`; otherwise the end event is forwarded to the wrapped
|
|
201
|
+
`handler`.
|
|
65
202
|
|
|
66
|
-
|
|
203
|
+
### `redirectHandler.onResponseError(controller, error)`
|
|
67
204
|
|
|
68
|
-
|
|
205
|
+
<!-- YAML
|
|
206
|
+
added: v7.0.0
|
|
207
|
+
-->
|
|
69
208
|
|
|
70
|
-
|
|
209
|
+
* `controller` {DispatchController} The controller for the in-flight request.
|
|
210
|
+
* `error` {Error} The error that occurred.
|
|
71
211
|
|
|
72
|
-
|
|
73
|
-
- **statusCode** `number` - The HTTP status code.
|
|
74
|
-
- **headers** `object` - The headers received in the response.
|
|
75
|
-
- **statusText** `string` - The status text.
|
|
212
|
+
Forwards the error to the wrapped `handler`.
|
|
76
213
|
|
|
77
|
-
|
|
214
|
+
### `redirectHandler.location`
|
|
78
215
|
|
|
79
|
-
|
|
216
|
+
<!-- YAML
|
|
217
|
+
added: v4.0.0
|
|
218
|
+
-->
|
|
80
219
|
|
|
81
|
-
|
|
220
|
+
* Type: {string|null}
|
|
82
221
|
|
|
83
|
-
|
|
84
|
-
|
|
222
|
+
The `Location` header value of the redirect currently being followed, or `null`
|
|
223
|
+
when no redirect is pending and the response is being passed through to the
|
|
224
|
+
wrapped `handler`.
|
|
85
225
|
|
|
86
|
-
|
|
226
|
+
### `redirectHandler.opts`
|
|
87
227
|
|
|
88
|
-
|
|
228
|
+
<!-- YAML
|
|
229
|
+
added: v7.12.0
|
|
230
|
+
-->
|
|
89
231
|
|
|
90
|
-
|
|
232
|
+
* Type: {DispatchOptions}
|
|
91
233
|
|
|
92
|
-
|
|
93
|
-
|
|
234
|
+
A copy of the dispatch options for the next request. It excludes the redirect
|
|
235
|
+
control fields (`maxRedirections`, `stripHeadersOnRedirect`, and
|
|
236
|
+
`stripHeadersOnCrossOriginRedirect`) and is mutated on each hop to reflect the
|
|
237
|
+
updated method, path, origin, and headers.
|
|
94
238
|
|
|
95
|
-
|
|
239
|
+
### `redirectHandler.maxRedirections`
|
|
96
240
|
|
|
97
|
-
|
|
241
|
+
<!-- YAML
|
|
242
|
+
added: v4.0.0
|
|
243
|
+
-->
|
|
98
244
|
|
|
99
|
-
|
|
245
|
+
* Type: {number|null}
|
|
100
246
|
|
|
101
|
-
|
|
247
|
+
The maximum number of redirects this handler will follow.
|
|
248
|
+
|
|
249
|
+
### `redirectHandler.handler`
|
|
250
|
+
|
|
251
|
+
<!-- YAML
|
|
252
|
+
added: v4.0.0
|
|
253
|
+
-->
|
|
254
|
+
|
|
255
|
+
* Type: {DispatchHandler}
|
|
256
|
+
|
|
257
|
+
The wrapped downstream handler that receives the lifecycle callbacks for the final
|
|
258
|
+
response.
|
|
259
|
+
|
|
260
|
+
### `redirectHandler.history`
|
|
261
|
+
|
|
262
|
+
<!-- YAML
|
|
263
|
+
added: v4.0.0
|
|
264
|
+
-->
|
|
265
|
+
|
|
266
|
+
* Type: {URL[]}
|
|
267
|
+
|
|
268
|
+
The ordered list of URLs visited while following redirects. It is used to enforce
|
|
269
|
+
`maxRedirections` and to detect redirect loops.
|
|
270
|
+
|
|
271
|
+
[`Agent`]: Agent.md#class-agent
|
|
272
|
+
[`Client`]: Client.md#class-client
|
|
273
|
+
[`Dispatcher`]: Dispatcher.md#class-dispatcher
|
|
274
|
+
[`DispatchHandler`]: Dispatcher.md#parameter-dispatchhandler
|
|
275
|
+
[`InvalidArgumentError`]: Errors.md#class-invalidargumenterror
|
|
276
|
+
[`Pool`]: Pool.md#class-pool
|
|
@@ -1,49 +1,136 @@
|
|
|
1
|
-
#
|
|
1
|
+
# RetryAgent
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<!--introduced_in=v6.7.0-->
|
|
4
|
+
<!--type=module-->
|
|
5
|
+
<!-- source_link=lib/dispatcher/retry-agent.js -->
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
Wraps a `undici.RetryHandler`.
|
|
7
|
+
> Stability: 2 - Stable
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
A [`Dispatcher`][] that automatically retries failed requests by wrapping
|
|
10
|
+
another dispatcher with the retry logic of [`RetryHandler`][]. Requests that fail
|
|
11
|
+
with a retryable status code or transport error are re-dispatched according to
|
|
12
|
+
the configured retry policy.
|
|
9
13
|
|
|
10
|
-
|
|
14
|
+
```mjs
|
|
15
|
+
import { RetryAgent } from 'undici'
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Class: `RetryAgent`
|
|
11
19
|
|
|
12
|
-
|
|
13
|
-
|
|
20
|
+
<!-- YAML
|
|
21
|
+
added: v6.7.0
|
|
22
|
+
-->
|
|
14
23
|
|
|
15
|
-
|
|
24
|
+
* Extends: {Dispatcher}
|
|
16
25
|
|
|
17
|
-
|
|
26
|
+
Wraps an existing dispatcher and applies retry behaviour to every request it
|
|
27
|
+
dispatches. Lifecycle methods such as [`retryAgent.close()`][] and
|
|
28
|
+
[`retryAgent.destroy()`][] are forwarded to the wrapped dispatcher.
|
|
18
29
|
|
|
19
|
-
|
|
20
|
-
- **retry** `(err: Error, context: RetryContext, callback: (err?: Error | null) => void) => void` (optional) - Function to be called after every retry. It should pass error if no more retries should be performed.
|
|
21
|
-
- **maxRetries** `number` (optional) - Maximum number of retries. Default: `5`
|
|
22
|
-
- **maxTimeout** `number` (optional) - Maximum number of milliseconds to wait before retrying. Default: `30000` (30 seconds)
|
|
23
|
-
- **minTimeout** `number` (optional) - Minimum number of milliseconds to wait before retrying. Default: `500` (half a second)
|
|
24
|
-
- **timeoutFactor** `number` (optional) - Factor to multiply the timeout by for each retry attempt. Default: `2`
|
|
25
|
-
- **retryAfter** `boolean` (optional) - It enables automatic retry after the `Retry-After` header is received. Default: `true`
|
|
26
|
-
- **methods** `string[]` (optional) - Array of HTTP methods to retry. Default: `['GET', 'HEAD', 'OPTIONS', 'PUT', 'DELETE', 'TRACE']`
|
|
27
|
-
- **statusCodes** `number[]` (optional) - Array of HTTP status codes to retry. Default: `[429, 500, 502, 503, 504]`
|
|
28
|
-
- **errorCodes** `string[]` (optional) - Array of Error codes to retry. Default: `['ECONNRESET', 'ECONNREFUSED', 'ENOTFOUND', 'ENETDOWN', 'ENETUNREACH', 'EHOSTDOWN', 'EHOSTUNREACH', 'EPIPE', 'UND_ERR_SOCKET']`
|
|
30
|
+
### `new RetryAgent(dispatcher[, options])`
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
<!-- YAML
|
|
33
|
+
added: v6.7.0
|
|
34
|
+
-->
|
|
31
35
|
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
* `dispatcher` {Dispatcher} The dispatcher to wrap and add retry behaviour to.
|
|
37
|
+
* `options` {RetryOptions} (optional)
|
|
38
|
+
* `throwOnError` {boolean} When `true`, an error is thrown on the final retry
|
|
39
|
+
attempt, preventing the following handlers from being called and destroying
|
|
40
|
+
the socket. Disable it when you need the response body for error responses
|
|
41
|
+
or when you provide a custom error handler. **Default:** `true`.
|
|
42
|
+
* `retry` {Function} Callback invoked on every retry iteration. It receives the
|
|
43
|
+
error, the current retry state, and a callback. Pass an error to the callback
|
|
44
|
+
to stop retrying, or call it with no argument to perform the retry.
|
|
45
|
+
* `err` {Error} The error that caused the retry attempt.
|
|
46
|
+
* `context` {RetryContext} The current retry context.
|
|
47
|
+
* `state` {RetryState} The mutable retry state.
|
|
48
|
+
* `counter` {number} The number of retries performed so far.
|
|
49
|
+
* `opts` {Object} The options passed to the retry handler, combining the
|
|
50
|
+
dispatch options with `retryOptions`.
|
|
51
|
+
* `callback` {Function} Called to continue. Pass an `Error` to stop retrying,
|
|
52
|
+
or `null`/`undefined` to perform the next retry.
|
|
53
|
+
* `maxRetries` {number} Maximum number of retries to allow. **Default:** `5`.
|
|
54
|
+
* `maxTimeout` {number} Maximum number of milliseconds to wait between retries.
|
|
55
|
+
**Default:** `30000` (30 seconds).
|
|
56
|
+
* `minTimeout` {number} Initial number of milliseconds to wait before the first
|
|
57
|
+
retry. **Default:** `500` (half a second).
|
|
58
|
+
* `timeoutFactor` {number} Factor by which the timeout is multiplied between
|
|
59
|
+
retries. **Default:** `2`.
|
|
60
|
+
* `retryAfter` {boolean} When `true`, the delay between retries is inferred from
|
|
61
|
+
the `Retry-After` response header when present. **Default:** `true`.
|
|
62
|
+
* `methods` {string[]} HTTP methods that are eligible for retry.
|
|
63
|
+
**Default:** `['GET', 'HEAD', 'OPTIONS', 'PUT', 'DELETE', 'TRACE']`.
|
|
64
|
+
* `statusCodes` {number[]} HTTP status codes that trigger a retry.
|
|
65
|
+
**Default:** `[500, 502, 503, 504, 429]`.
|
|
66
|
+
* `errorCodes` {string[]} Transport error codes that trigger a retry.
|
|
67
|
+
**Default:** `['ECONNRESET', 'ECONNREFUSED', 'ENOTFOUND', 'ENETDOWN', 'ENETUNREACH', 'EHOSTDOWN', 'EHOSTUNREACH', 'EPIPE', 'UND_ERR_SOCKET']`.
|
|
34
68
|
|
|
35
|
-
|
|
69
|
+
Creates a new `RetryAgent` that wraps `dispatcher`. The `options` are stored and
|
|
70
|
+
used to construct a [`RetryHandler`][] for each dispatched request.
|
|
36
71
|
|
|
37
|
-
```
|
|
72
|
+
```mjs
|
|
38
73
|
import { Agent, RetryAgent } from 'undici'
|
|
39
74
|
|
|
40
|
-
const agent = new RetryAgent(new Agent()
|
|
75
|
+
const agent = new RetryAgent(new Agent(), {
|
|
76
|
+
maxRetries: 3,
|
|
77
|
+
minTimeout: 1000,
|
|
78
|
+
timeoutFactor: 2,
|
|
79
|
+
})
|
|
41
80
|
|
|
42
81
|
const res = await agent.request({
|
|
43
82
|
method: 'GET',
|
|
44
83
|
origin: 'http://example.com',
|
|
45
84
|
path: '/',
|
|
46
85
|
})
|
|
86
|
+
|
|
47
87
|
console.log(res.statusCode)
|
|
48
88
|
console.log(await res.body.text())
|
|
49
89
|
```
|
|
90
|
+
|
|
91
|
+
### `retryAgent.dispatch(options, handler)`
|
|
92
|
+
|
|
93
|
+
<!-- YAML
|
|
94
|
+
added: v6.7.0
|
|
95
|
+
-->
|
|
96
|
+
|
|
97
|
+
* `options` {DispatchOptions} The dispatch options, identical to
|
|
98
|
+
[`dispatcher.dispatch()`][].
|
|
99
|
+
* `handler` {DispatchHandler} The dispatch handler.
|
|
100
|
+
* Returns: {boolean}
|
|
101
|
+
|
|
102
|
+
Dispatches `options` through the wrapped dispatcher, installing a
|
|
103
|
+
[`RetryHandler`][] that applies the configured retry policy before delegating to
|
|
104
|
+
`handler`. Returns `false` if the dispatcher is busy and the caller should wait
|
|
105
|
+
before dispatching again, otherwise `true`.
|
|
106
|
+
|
|
107
|
+
### `retryAgent.close()`
|
|
108
|
+
|
|
109
|
+
<!-- YAML
|
|
110
|
+
added: v6.7.0
|
|
111
|
+
-->
|
|
112
|
+
|
|
113
|
+
* Returns: {Promise} Resolves when the wrapped dispatcher has closed.
|
|
114
|
+
|
|
115
|
+
Gracefully closes the wrapped dispatcher, waiting for in-flight requests to
|
|
116
|
+
complete. Equivalent to calling [`dispatcher.close()`][] on the wrapped
|
|
117
|
+
dispatcher.
|
|
118
|
+
|
|
119
|
+
### `retryAgent.destroy()`
|
|
120
|
+
|
|
121
|
+
<!-- YAML
|
|
122
|
+
added: v6.7.0
|
|
123
|
+
-->
|
|
124
|
+
|
|
125
|
+
* Returns: {Promise} Resolves when the wrapped dispatcher has been destroyed.
|
|
126
|
+
|
|
127
|
+
Forcefully destroys the wrapped dispatcher, aborting all pending requests.
|
|
128
|
+
Equivalent to calling [`dispatcher.destroy()`][] on the wrapped dispatcher.
|
|
129
|
+
|
|
130
|
+
[`Dispatcher`]: Dispatcher.md#class-dispatcher
|
|
131
|
+
[`RetryHandler`]: RetryHandler.md#class-retryhandler
|
|
132
|
+
[`dispatcher.close()`]: Dispatcher.md#dispatcherclosecallback
|
|
133
|
+
[`dispatcher.destroy()`]: Dispatcher.md#dispatcherdestroyerror-callback
|
|
134
|
+
[`dispatcher.dispatch()`]: Dispatcher.md#dispatcherdispatchoptions-handler
|
|
135
|
+
[`retryAgent.close()`]: #retryagentclose
|
|
136
|
+
[`retryAgent.destroy()`]: #retryagentdestroy
|