[whatwg/fetch] Sending trailers (PR #1941)

Adds an option for sending trailing header fields. Ensures that the mechanism is entirely optional for implementers, and all existing implementations that just don't handle trailers should be out-of-the-box compliant.

Builds on https://github.com/whatwg/fetch/pull/1940 (the first commit in here is from that PR)

---

- [ ] At least two implementers are interested (and none opposed):
   * …
   * …
- [ ] [Tests](https://github.com/web-platform-tests/wpt) are written and can be reviewed and commented upon at:
   * … <!-- If these tests are tentative, link a PR to make them non-tentative. -->
- [ ] [Implementation bugs](https://github.com/whatwg/meta/blob/main/MAINTAINERS.md#handling-pull-requests) are filed:
   * Chromium: …
   * Gecko: …
   * WebKit: …
   * Deno (not for CORS changes): …
- [ ] [MDN issue](https://github.com/whatwg/meta/blob/main/MAINTAINERS.md#handling-pull-requests) is filed: …
- [ ] The top of this comment includes a [clear commit message](https://github.com/whatwg/meta/blob/main/COMMITTING.md) to use. <!-- If you created this PR from a single commit, Github copied its message. Otherwise, you need to add a commit message yourself. -->

(See [WHATWG Working Mode: Changes](https://whatwg.org/working-mode#changes) for more details.)


<!--
    This comment and the below content is programmatically generated.
    You may add a comma-separated list of anchors you'd like a
    direct link to below (e.g. #idl-serializers, #idl-sequence):

    Don't remove this comment or modify anything below this line.
    If you don't want a preview generated for this pull request,
    just replace the whole of this comment's content by "no preview"
    and remove what's below.
-->
***

### :boom: Error: 422 Unprocessable Entity :boom: ###

[PR Preview](https://github.com/tobie/pr-preview#pr-preview) failed to build. _(Last tried on Jul 11, 2026, 5:59 PM UTC)_.

<details>
<summary>More</summary>


PR Preview relies on a number of web services to run. There seems to be an issue with the following one:

:rotating_light: [Spec Generator](https://www.w3.org/publications/spec-generator/) - Spec Generator is the web service used to build bikeshed/ReSpec specs

:link: [Related URL](https://www.w3.org/publications/spec-generator/?type=bikeshed-spec&output=html&url=https%3A%2F%2Fraw.githubusercontent.com%2Fjasnell%2Ffetch%2Fb0c272ed76e0bbededc68b57ee1a627c0506a372%2Ffetch.bs&force=1&md-status=LS-PR&md-Text-Macro=PR-NUMBER%201941)

**Error output:**

```json
[
    {
        "lineNum": "1676:17",
        "messageType": "link",
        "text": "Multiple possible 'dfn' local refs for 'trailer state'.\nRandomly chose one of them; other instances might get a different random choice."
    },
    {
        "lineNum": "1681:51",
        "messageType": "link",
        "text": "Multiple possible 'dfn' local refs for 'trailer state'.\nRandomly chose one of them; other instances might get a different random choice."
    },
    {
        "lineNum": "1701:48",
        "messageType": "link",
        "text": "Multiple possible 'dfn' local refs for 'trailer state'.\nRandomly chose one of them; other instances might get a different random choice."
    },
    {
        "lineNum": "1724:50",
        "messageType": "link",
        "text": "Multiple possible 'dfn' local refs for 'trailer state'.\nRandomly chose one of them; other instances might get a different random choice."
    },
    {
        "lineNum": "2466:4",
        "messageType": "link",
        "text": "Multiple possible 'dfn' local refs for 'trailer state'.\nRandomly chose one of them; other instances might get a different random choice."
    },
    {
        "lineNum": "2466:63",
        "messageType": "link",
        "text": "Multiple possible 'dfn' local refs for 'trailer state'.\nRandomly chose one of them; other instances might get a different random choice."
    },
    {
        "lineNum": "2751:4",
        "messageType": "link",
        "text": "Multiple possible 'dfn' local refs for 'trailer state'.\nRandomly chose one of them; other instances might get a different random choice."
    },
    {
        "lineNum": "2751:63",
        "messageType": "link",
        "text": "Multiple possible 'dfn' local refs for 'trailer state'.\nRandomly chose one of them; other instances might get a different random choice."
    },
    {
        "lineNum": "9514:48",
        "messageType": "link",
        "text": "Multiple possible 'dfn' local refs for 'trailer state'.\nRandomly chose one of them; other instances might get a different random choice."
    },
    {
        "lineNum": "6996:7",
        "messageType": "lint",
        "text": "RFC2119 keyword in non-normative section (use: might, can, has to, or override with <span class=allow-2119>): Sending trailer fields is entirely optional.\n      Implementations that do not support sending trailer fields are fully\n      compliant with this specification. The "
    },
    {
        "lineNum": "6996:7",
        "messageType": "lint",
        "text": "RFC2119 keyword in non-normative section (use: might, can, has to, or override with <span class=allow-2119>):  algorithm (which is called during\n      request construction), so implementations that ignore the trailer state\n      do not cause unhandled promise rejections.\n      Whether or not to actually forward trailer fields is an implementation\n      decision, consistent with how HTTP intermediaries may forward, discard,\n      or store trailer fields\n      ("
    },
    {
        "lineNum": "9012:4",
        "messageType": "lint",
        "text": "RFC2119 keyword in non-normative section (use: might, can, has to, or override with <span class=allow-2119>):  providing trailer fields to send after the\n   request body. Trailer field names must be pre-declared in the `"
    },
    {
        "lineNum": "9012:4",
        "messageType": "lint",
        "text": "RFC2119 keyword in non-normative section (use: might, can, has to, or override with <span class=allow-2119>): ` header;\n   undeclared trailer fields are silently dropped. Implementations are not required to send\n   trailer fields and may ignore this option entirely.\n  "
    },
    {
        "lineNum": "9099:3",
        "messageType": "lint",
        "text": "RFC2119 keyword in non-normative section (use: might, can, has to, or override with <span class=allow-2119>):  promise, not the timing of body\n  transmission. This may indirectly reveal when payload processing completes if\n  the caller ties the promise to body consumption (e.g., computing a digest over\n  the body stream), but this timing is controlled by the caller, not the\n  implementation.\n\n "
    },
    {
        "lineNum": "1795:7",
        "messageType": "lint",
        "text": "Unexported dfn for 'ignore a trailers init' that's not referenced locally - did you mean to export it?"
    },
    {
        "lineNum": null,
        "messageType": "failure",
        "text": "Did not generate, due to errors exceeding the allowed error level."
    }
]
```

_This seems to be an issue with the [Spec Generator](https://www.w3.org/publications/spec-generator/) service. PR Preview doesn't manage this service and so has no control over it. If you've identified an issue with it, you can [report the issue to the maintainers of Spec Generator](https://github.com/w3c/spec-generator/issues/new) directly. Please be courteous. Thank you!_

_If you don't have enough information above to solve the error by yourself or if the issue doesn't seem related to Spec Generator, you can [file an issue with PR Preview](https://github.com/tobie/pr-preview/issues/new?title=Unidentified%20Error&body=See%20whatwg/fetch%231941.)._

</details>

You can view, comment on, or merge this pull request online at:

  https://github.com/whatwg/fetch/pull/1941

-- Commit Summary --

  * Add .trailers to Response/Request
  * Support sending trailers with new option

-- File Changes --

    M fetch.bs (527)

-- Patch Links --

https://github.com/whatwg/fetch/pull/1941.patch
https://github.com/whatwg/fetch/pull/1941.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/pull/1941
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/fetch/pull/1941@github.com>

Received on Saturday, 11 July 2026 17:59:31 UTC