From a9713742db9febadb805b84c2f5748f8567ec31b Mon Sep 17 00:00:00 2001 From: Qing Guo Date: Thu, 10 Sep 2026 19:29:36 +0800 Subject: [PATCH] [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 --- src/content/docs/workers/runtime-apis/request.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/content/docs/workers/runtime-apis/request.mdx b/src/content/docs/workers/runtime-apis/request.mdx index ac7f6b9e012..24bd472169d 100644 --- a/src/content/docs/workers/runtime-apis/request.mdx +++ b/src/content/docs/workers/runtime-apis/request.mdx @@ -87,7 +87,7 @@ An object containing properties that you want to apply to the request. * `redirect` - * 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`. + * 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. * `signal` AbortSignal optional * 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 * `redirect` string read-only - * 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`. + * 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`. * `signal` AbortSignal read-only * 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.