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

The default RPC transport now requests wire compression in Node #3340

Conversation

steveluscher
Copy link
Collaborator

@steveluscher steveluscher commented Oct 6, 2024

Summary

The fetch API in browsers automatically requests the wire compression encoding that the browser supports, in the order it wants it. Node's fetch API does not.

In this PR we add all of the default algorithms supported by Node LTS at the time of writing.

Closes #3338.

Test Plan

  1. Install Node LTS (n lts)
  2. Test that it actually supports these
> await (await fetch('https://httpbin.org/deflate', {headers:{'Accept-Encoding': 'deflate', 'Content-Type': 'application/json'}})).json()
{
  deflated: true,
  headers: {
    Accept: '*/*',
    'Accept-Encoding': 'deflate',
    'Accept-Language': '*',
    'Content-Type': 'application/json',
    Host: 'httpbin.org',
    'Sec-Fetch-Mode': 'cors',
    'User-Agent': 'node',
    'X-Amzn-Trace-Id': 'Root=1-67020914-22d36c347b3b8b0f356d9a98'
  },
  method: 'GET',
  origin: '145.40.88.235'
}
> await (await fetch('https://httpbin.org/gzip', {headers:{'Accept-Encoding': 'gzip', 'Content-Type': 'application/json'}})).json()
{
  gzipped: true,
  headers: {
    Accept: '*/*',
    'Accept-Encoding': 'gzip',
    'Accept-Language': '*',
    'Content-Type': 'application/json',
    Host: 'httpbin.org',
    'Sec-Fetch-Mode': 'cors',
    'User-Agent': 'node',
    'X-Amzn-Trace-Id': 'Root=1-67020916-28ed8e6b0b8c612f3be0f76f'
  },
  method: 'GET',
  origin: '145.40.88.235'
}
> await (await fetch('https://httpbin.org/brotli', {headers:{'Accept-Encoding': 'br', 'Content-Type': 'application/json'}})).json()
{
  brotli: true,
  headers: {
    Accept: '*/*',
    'Accept-Encoding': 'br',
    'Accept-Language': '*',
    'Content-Type': 'application/json',
    Host: 'httpbin.org',
    'Sec-Fetch-Mode': 'cors',
    'User-Agent': 'node',
    'X-Amzn-Trace-Id': 'Root=1-6702091a-1a5970103512353b1eafdfcf'
  },
  method: 'GET',
  origin: '145.40.88.235'
}

Copy link

changeset-bot bot commented Oct 6, 2024

🦋 Changeset detected

Latest commit: 9662353

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @steveluscher and the rest of your teammates on Graphite Graphite

@steveluscher steveluscher force-pushed the 10-06-the_default_rpc_transport_now_requests_wire_compression_in_node branch 2 times, most recently from 1cf75f3 to e6455c7 Compare October 6, 2024 04:29
@steveluscher steveluscher force-pushed the 10-06-the_default_rpc_transport_now_requests_wire_compression_in_node branch from e6455c7 to 9662353 Compare October 6, 2024 04:39
@steveluscher steveluscher added the automerge Merge this Pull Request automatically once CI passes label Oct 6, 2024
@mergify mergify bot merged commit 44c8772 into master Oct 6, 2024
9 checks passed
@mergify mergify bot deleted the 10-06-the_default_rpc_transport_now_requests_wire_compression_in_node branch October 6, 2024 04:44
@github-actions github-actions bot mentioned this pull request Oct 6, 2024
@steveluscher steveluscher mentioned this pull request Oct 7, 2024
Copy link
Contributor

Because there has been no activity on this PR for 14 days since it was merged, it has been automatically locked. Please open a new issue if it requires a follow up.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
automerge Merge this Pull Request automatically once CI passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set the Accept-Encoding: gzip header by default for all RPC calls
1 participant