Skip to content

Commit a971374

Browse files
[Workers] Request redirect mode: only follow and manual are supported
The Request page listed `error` as a valid redirect mode in both the RequestInit option and the read-only property. workerd rejects it at Request construction with a TypeError ("Invalid redirect value, must be one of "follow" or "manual" ("error" won't be implemented since it does not make sense at the edge; use "manual" and check the response status code)."), so a Worker that passes it never sends the request. Document the two supported values and the behaviour of `error`. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 72c8124 commit a971374

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/content/docs/workers/runtime-apis/request.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ An object containing properties that you want to apply to the request.
8787

8888
* `redirect` <Type text="string" /> <MetaInfo text="optional" />
8989

90-
* The redirect mode to use: `follow`, `error`, or `manual`. The default for a new `Request` object is `follow`. Note, however, that the incoming `Request` property of a `FetchEvent` will have redirect mode `manual`.
90+
* The redirect mode to use: `follow` or `manual`. The default for a new `Request` object is `follow`. Note, however, that the incoming `Request` property of a `FetchEvent` will have redirect mode `manual`. Workers does not implement the `error` mode from the Fetch standard: passing `redirect: "error"` throws a `TypeError` as soon as the `Request` is constructed (including inside `fetch(url, init)`), before any request is sent. Use `manual` and check the status code of the returned response instead.
9191

9292
* `signal` AbortSignal optional
9393
* If provided, the request can be canceled by triggering an abort on the corresponding `AbortController`.
@@ -262,7 +262,7 @@ All properties of an incoming `Request` object (the request you receive from the
262262

263263
* `redirect` string read-only
264264

265-
* The redirect mode to use: `follow`, `error`, or `manual`. The `fetch` method will automatically follow redirects if the redirect mode is set to `follow`. If set to `manual`, the `3xx` redirect response will be returned to the caller as-is. The default for a new `Request` object is `follow`. Note, however, that the incoming `Request` property of a `FetchEvent` will have redirect mode `manual`.
265+
* The redirect mode to use: `follow` or `manual`. The `fetch` method will automatically follow redirects if the redirect mode is set to `follow`. If set to `manual`, the `3xx` redirect response will be returned to the caller as-is. The `error` mode from the Fetch standard is not implemented in Workers, and passing it throws a `TypeError` when the `Request` is constructed. The default for a new `Request` object is `follow`. Note, however, that the incoming `Request` property of a `FetchEvent` will have redirect mode `manual`.
266266

267267
* `signal` AbortSignal read-only
268268
* The `AbortSignal` corresponding to this request. If you use the [`enable_request_signal`](/workers/configuration/compatibility-flags/#enable-requestsignal-for-incoming-requests) compatibility flag, you can attach an event listener to the signal. This allows you to perform cleanup tasks or write to logs before your Worker's invocation ends.

0 commit comments

Comments
 (0)