Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firefox supports Server-Timing as HTTP trailer, but only exposes it to DevTools #25141

Merged
merged 4 commits into from
Nov 22, 2024

Conversation

bsmth
Copy link
Member

@bsmth bsmth commented Nov 20, 2024

Summary

The support for HTTP Trailer header is misleading, as it's removed from the Fetch spec & not accessible there anyway / XHR. As far as I can see, the only support that exists in browsers is exclusively for Server-Timing, and at that, it's only used for DevTools in Network -> Timing, all other headers (as trailers) are a no-op / discarded. For this reason, I've set it to partial support for Trailer, and full support for Server-Timing header as trailer, which no other browser appears to do.

Test results and supporting details

Node repro:

const http = require("http");
http
  .createServer((req, res) => {
    res.writeHead(200, {
      "Content-Type": "text/plain",
      "Transfer-Encoding": "chunked",
      // Server-Timing as header
      // "Server-Timing": "custom-metric;dur=567.123",
      Trailer: "Server-Timing",
    });
    res.write("Hello.\n");
    // Server-Timing as trailer
    // See https://nodejs.org/api/http.html#responseaddtrailersheaders
    res.addTrailers({
      "Server-Timing": "custom-metric;dur=666.123",
    });
    res.end();
  })
  .listen(3000, () => {
    console.log("Server running at http://localhost:3000");
  });

Related issues

@github-actions github-actions bot added the data:http Compat data for HTTP features. https://developer.mozilla.org/docs/Web/HTTP label Nov 20, 2024
@github-actions github-actions bot added the size:m [PR only] 25-100 LoC changed label Nov 20, 2024
@caugner
Copy link
Contributor

caugner commented Nov 21, 2024

FWIW I only found this indirectly related WebKit bug: https://bugs.webkit.org/show_bug.cgi?id=178069

Copy link
Contributor

@caugner caugner left a comment

Choose a reason for hiding this comment

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

LGTM.

Compact diff grouped by file:
image

Copy link
Contributor

@caugner caugner left a comment

Choose a reason for hiding this comment

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

One nit.

http/headers/Server-Timing.json Outdated Show resolved Hide resolved
@bsmth bsmth requested a review from caugner November 22, 2024 09:18
@caugner caugner changed the title chore(http): Clarify Trailer support, partial support for Server-Timing in Fx devtools only Server-Timing/Trailer headers are only partially supported by Firefox Nov 22, 2024
@caugner caugner changed the title Server-Timing/Trailer headers are only partially supported by Firefox Firefox recognizes Server-Timing header, but only partially supports Trailer headers (DevTools only) Nov 22, 2024
@caugner caugner merged commit af6c908 into mdn:main Nov 22, 2024
7 checks passed
@caugner caugner changed the title Firefox recognizes Server-Timing header, but only partially supports Trailer headers (DevTools only) Firefox recognizes Server-Timing header, but only partially supports it as Trailer (DevTools only) Nov 22, 2024
@mdn-bot mdn-bot mentioned this pull request Nov 22, 2024
@caugner caugner changed the title Firefox recognizes Server-Timing header, but only partially supports it as Trailer (DevTools only) Firefox supports Server-Timing header, but only partially supports it as Trailer (DevTools only) Nov 22, 2024
@caugner caugner changed the title Firefox supports Server-Timing header, but only partially supports it as Trailer (DevTools only) Firefox supports Server-Timing as HTTP trailer, but only exposes it to DevTools Nov 22, 2024
@bsmth bsmth deleted the 18441-http-trailer branch November 22, 2024 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data:http Compat data for HTTP features. https://developer.mozilla.org/docs/Web/HTTP size:m [PR only] 25-100 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants