[whatwg/fetch] Add .trailers to Response/Request (PR #1940)

Adds `Promise<Headers>` `trailers` properties to `Request` and `Response`

When sending... `trailers` resolves to an empty, immutable `Headers` since we're not dealing with sending trailers in this change.

When receiving... `trailers` resolves to an immutable, populated/filtered `Headers` resolved after the body is completed. This means the trailers promise will not resolve if the body is not consumed.

```js
const trailers = await response.trailers;
```

---

- [ ] At least two implementers are interested (and none opposed):
   * Node.js
   * Cloudflare Workers
   * …
- [ ] [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, 3:12 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%2Faca5d2b445b73fe61091ad056a1a653ad328303a%2Ffetch.bs&force=1&md-status=LS-PR&md-Text-Macro=PR-NUMBER%201940)

**Error output:**

```json
[
    {
        "lineNum": null,
        "messageType": "warning",
        "text": "Multiple elements have the same id 'trailer-state':\n  <h4> on line 1654:1, <dfn> on line 1656:6\nDeduping, but this ID may not be stable across revisions."
    },
    {
        "lineNum": "1675: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": "1679: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": "1699: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": "2652: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": "2652: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": "9442:2",
        "messageType": "link",
        "text": "No 'dfn' refs found for 'resolve a promise'."
    },
    {
        "lineNum": "9791:36",
        "messageType": "link",
        "text": "No 'dfn' refs found for 'create a new promise'."
    },
    {
        "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%231940.)._

</details>

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

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

-- Commit Summary --

  * Add .trailers to Response/Request

-- File Changes --

    M fetch.bs (296)

-- Patch Links --

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

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

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

Received on Saturday, 11 July 2026 15:12:40 UTC