Skip to content

feat(ext/fetch): support priority in RequestInit#34716

Merged
bartlomieju merged 4 commits into
mainfrom
feat/request-priority-16502
Jun 6, 2026
Merged

feat(ext/fetch): support priority in RequestInit#34716
bartlomieju merged 4 commits into
mainfrom
feat/request-priority-16502

Conversation

@bartlomieju

@bartlomieju bartlomieju commented Jun 2, 2026

Copy link
Copy Markdown
Member

Adds the priority member from the Fetch standard to RequestInit
("auto" | "high" | "low").

Before this, new Request(url, { priority }) silently ignored the option
and passing an invalid value did not throw, diverging from browsers and
Node. This follows up #34607, which added the other missing Request
properties but left out priority.

In the Fetch standard priority is a write-only RequestInit member, not
a readonly attribute on the Request interface, so it is accepted and
validated but intentionally not exposed back as request.priority. The WPT
fetch/api/request/request-structure test asserts exactly this ("Request
does not expose priority attribute"), and browsers behave the same way.

Changes:

  • add the RequestPriority enum converter so init.priority is validated
    and invalid values throw a TypeError
  • wire init.priority through the constructor and cloneInnerRequest
  • add RequestPriority and RequestInit.priority to lib.deno_fetch.d.ts
  • extend tests/unit/request_test.ts and flip the request-init-priority
    WPT expectations to passing

As with the other request properties, the value isn't acted upon by the
underlying networking stack (priority hints have no meaningful effect in a
server runtime); this is for spec/browser parity.

Closes #16502

`Request`/`RequestInit` were missing the `priority` member from the
Fetch standard ("auto" | "high" | "low"), so `new Request(url, { priority })`
silently ignored the option, `request.priority` was `undefined`, and an
invalid value did not throw.

This adds the `RequestPriority` enum, the `priority` getter (defaulting
to "auto"), and wires the option through the constructor and
`cloneInnerRequest`. As with the other request properties, the value is
not acted upon by the underlying networking stack (priority hints have no
effect in a server runtime); this is for spec/browser parity.

Closes #16502
Per the Fetch spec, priority is a RequestInit member (write-only init
option), not a readonly attribute on the Request interface. Exposing it
as a getter failed WPT fetch/api/request/request-structure.any.js, which
asserts Request does not expose the priority attribute.

Keep the RequestInit.priority side: it is still accepted, validated as a
RequestPriority enum (invalid values throw), and stored internally. Only
the public getter and its .d.ts declaration are removed.
@bartlomieju bartlomieju changed the title feat(ext/fetch): support priority on Request and RequestInit feat(ext/fetch): support priority in RequestInit Jun 6, 2026
@bartlomieju
bartlomieju enabled auto-merge (squash) June 6, 2026 12:32
@bartlomieju
bartlomieju merged commit 6405d83 into main Jun 6, 2026
269 of 271 checks passed
@bartlomieju
bartlomieju deleted the feat/request-priority-16502 branch June 6, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for Priority Hints

1 participant