Skip to content

Add .trailers to Response/Request#1940

Open
jasnell wants to merge 1 commit into
whatwg:mainfrom
jasnell:jasnell/trailers
Open

Add .trailers to Response/Request#1940
jasnell wants to merge 1 commit into
whatwg:mainfrom
jasnell:jasnell/trailers

Conversation

@jasnell

@jasnell jasnell commented Jul 11, 2026

Copy link
Copy Markdown

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.

const trailers = await response.trailers;

The minimal conformance requirement here is the presence of the .trailers property. An implementation which chooses not to actually support trailers would need only return a resolved promise with an immutable empty Headers. Nothing in this should be interpreted as requiring any implementation to actually implement trailers support.

Refs: #981


  • At least two implementers are interested (and none opposed):
    • Node.js
    • Cloudflare Workers
  • Tests are written and can be reviewed and commented upon at:
  • Implementation bugs are filed:
    • Chromium: …
    • Gecko: …
    • WebKit: …
    • Deno (not for CORS changes): …
  • MDN issue is filed: …
  • The top of this comment includes a clear commit message to use.

(See WHATWG Working Mode: Changes for more details.)


💥 Error: 422 Unprocessable Entity 💥

PR Preview failed to build. (Last tried on Jul 11, 2026, 5:40 PM UTC).

More

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

🚨 Spec Generator - Spec Generator is the web service used to build bikeshed/ReSpec specs

🔗 Related URL

Error output:

[
    {
        "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": 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 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 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.

Comment thread fetch.bs
<p>A <dfn export>trailer state</dfn> is a <a for=/>struct</a> used to represent
HTTP trailer fields received after a response body
([[HTTP]], <a href="https://httpwg.org/specs/rfc9110.html#trailers">Section 6.5</a>).
It has:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The struct here is really only to deal with cloning... wasn't sure if it would be better to go more specific / concrete or to describe things in a more generic / hand wavy way... went with more specific.

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.
@jasnell jasnell force-pushed the jasnell/trailers branch from aca5d2b to 3cbc607 Compare July 11, 2026 17:08
@jasnell jasnell mentioned this pull request Jul 11, 2026
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant