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

feat: strip traceparent header from cachekey #64499

Merged
merged 2 commits into from
Apr 15, 2024

Conversation

Jeffrey-Zutt
Copy link
Contributor

@Jeffrey-Zutt Jeffrey-Zutt commented Apr 15, 2024

What?

We strip the traceparent header from the cache-key.

Why?

The traceparent header forms part of the W3C Trace Context standard, installed to track individual HTTP requests from start to end across multiple services. That means each individual HTTP request will have a unique traceparent value, reflecting its unique journey across servers and services.

If we include the traceparent header in the cache key, the uniqueness of the traceparent means the cache key would always be different even for requests that should yield the same response. This would cause the cache to always miss and re-process the request.

Effectively rendering fetch-cache useless.

@ijjk
Copy link
Member

ijjk commented Apr 15, 2024

Allow CI Workflow Run

  • approve CI run for commit: ab67421

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

vanesterik
vanesterik approved these changes Apr 15, 2024
Copy link
Member

@ijjk ijjk left a comment

Choose a reason for hiding this comment

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

This change makes sense to me, thanks for the PR!

@ijjk ijjk enabled auto-merge (squash) April 15, 2024 15:07
@Jeffrey-Zutt
Copy link
Contributor Author

Jeffrey-Zutt commented Apr 15, 2024

Thanks @ijjk! let me know if you want me to make any changes :-)

@ijjk
Copy link
Member

ijjk commented Apr 15, 2024

Stats from current PR

Default Build
General Overall increase ⚠️
vercel/next.js canary Jeffrey-Zutt/next.js strip-traceparent-from-cachekey Change
buildDuration 14.1s 14s N/A
buildDurationCached 7.6s 6.3s N/A
nodeModulesSize 199 MB 199 MB ⚠️ +1.53 kB
nextStartRea..uration (ms) 404ms 404ms
Client Bundles (main, webpack)
vercel/next.js canary Jeffrey-Zutt/next.js strip-traceparent-from-cachekey Change
2453-HASH.js gzip 31.4 kB 31.4 kB N/A
3304.HASH.js gzip 181 B 181 B
3f784ff6-HASH.js gzip 53.7 kB 53.7 kB
8299-HASH.js gzip 5.1 kB 5.1 kB N/A
framework-HASH.js gzip 45.2 kB 45.2 kB
main-app-HASH.js gzip 242 B 241 B N/A
main-HASH.js gzip 32.2 kB 32.2 kB N/A
webpack-HASH.js gzip 1.68 kB 1.68 kB N/A
Overall change 99 kB 99 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary Jeffrey-Zutt/next.js strip-traceparent-from-cachekey Change
polyfills-HASH.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary Jeffrey-Zutt/next.js strip-traceparent-from-cachekey Change
_app-HASH.js gzip 196 B 197 B N/A
_error-HASH.js gzip 184 B 184 B
amp-HASH.js gzip 505 B 505 B
css-HASH.js gzip 324 B 325 B N/A
dynamic-HASH.js gzip 2.5 kB 2.5 kB N/A
edge-ssr-HASH.js gzip 258 B 258 B
head-HASH.js gzip 352 B 352 B
hooks-HASH.js gzip 370 B 371 B N/A
image-HASH.js gzip 4.27 kB 4.27 kB
index-HASH.js gzip 259 B 259 B
link-HASH.js gzip 2.67 kB 2.67 kB N/A
routerDirect..HASH.js gzip 314 B 312 B N/A
script-HASH.js gzip 386 B 386 B
withRouter-HASH.js gzip 309 B 309 B
1afbb74e6ecf..834.css gzip 106 B 106 B
Overall change 6.63 kB 6.63 kB
Client Build Manifests
vercel/next.js canary Jeffrey-Zutt/next.js strip-traceparent-from-cachekey Change
_buildManifest.js gzip 483 B 485 B N/A
Overall change 0 B 0 B
Rendered Page Sizes
vercel/next.js canary Jeffrey-Zutt/next.js strip-traceparent-from-cachekey Change
index.html gzip 528 B 528 B
link.html gzip 541 B 540 B N/A
withRouter.html gzip 524 B 522 B N/A
Overall change 528 B 528 B
Edge SSR bundle Size
vercel/next.js canary Jeffrey-Zutt/next.js strip-traceparent-from-cachekey Change
edge-ssr.js gzip 95.6 kB 95.6 kB N/A
page.js gzip 3.06 kB 3.06 kB N/A
Overall change 0 B 0 B
Middleware size
vercel/next.js canary Jeffrey-Zutt/next.js strip-traceparent-from-cachekey Change
middleware-b..fest.js gzip 625 B 624 B N/A
middleware-r..fest.js gzip 155 B 156 B N/A
middleware.js gzip 25.5 kB 25.5 kB N/A
edge-runtime..pack.js gzip 839 B 839 B
Overall change 839 B 839 B
Next Runtimes
vercel/next.js canary Jeffrey-Zutt/next.js strip-traceparent-from-cachekey Change
app-page-exp...dev.js gzip 171 kB 171 kB
app-page-exp..prod.js gzip 97.5 kB 97.5 kB
app-page-tur..prod.js gzip 99.2 kB 99.2 kB
app-page-tur..prod.js gzip 93.5 kB 93.5 kB
app-page.run...dev.js gzip 145 kB 145 kB
app-page.run..prod.js gzip 92 kB 92 kB
app-route-ex...dev.js gzip 21.5 kB 21.5 kB
app-route-ex..prod.js gzip 15.2 kB 15.2 kB
app-route-tu..prod.js gzip 15.2 kB 15.2 kB
app-route-tu..prod.js gzip 14.9 kB 14.9 kB
app-route.ru...dev.js gzip 21.1 kB 21.1 kB
app-route.ru..prod.js gzip 14.9 kB 14.9 kB
pages-api-tu..prod.js gzip 9.55 kB 9.55 kB
pages-api.ru...dev.js gzip 9.82 kB 9.82 kB
pages-api.ru..prod.js gzip 9.55 kB 9.55 kB
pages-turbo...prod.js gzip 22.5 kB 22.5 kB
pages.runtim...dev.js gzip 23.1 kB 23.1 kB
pages.runtim..prod.js gzip 22.5 kB 22.5 kB
server.runti..prod.js gzip 51.3 kB 51.4 kB N/A
Overall change 897 kB 897 kB
build cache
vercel/next.js canary Jeffrey-Zutt/next.js strip-traceparent-from-cachekey Change
0.pack gzip 1.58 MB 1.58 MB N/A
index.pack gzip 107 kB 106 kB N/A
Overall change 0 B 0 B
Diff details
Diff for middleware.js

Diff too large to display

Diff for edge-ssr.js

Diff too large to display

Diff for server.runtime.prod.js

Diff too large to display

Commit: cfc3d37

@ijjk ijjk merged commit 512cabc into vercel:canary Apr 15, 2024
73 checks passed
ztanner pushed a commit that referenced this pull request Apr 17, 2024
### What?
We strip the `traceparent` header from the cache-key.

### Why?
The traceparent header forms part of the W3C Trace Context standard,
installed to track individual HTTP requests from start to end across
multiple services. That means each individual HTTP request will have a
unique traceparent value, reflecting its unique journey across servers
and services.

If we include the traceparent header in the cache key, the uniqueness of
the traceparent means the cache key would always be different even for
requests that should yield the same response. This would cause the cache
to always miss and re-process the request.

Effectively rendering fetch-cache useless.

Co-authored-by: Jeffrey <[email protected]>
ijjk added a commit that referenced this pull request Apr 19, 2024
…rom original object (#64727)

### What?

I submitted PR #64499 , it got merged, but it contains a mistake.
I'm terribly sorry about this!

By removing the traceparent from the cachekey, we mistakenly removed the
header from the original object.
Causing the actual request to be executed without the traceparent
header.

### Why?

Creating a cachekey should not alter the original object.

### How?

Flip the arguments for Object.assign

---------

Co-authored-by: Jeffrey <[email protected]>
Co-authored-by: JJ Kasper <[email protected]>
eps1lon added a commit that referenced this pull request Apr 21, 2024
commit ea37c04
Author: Hendrik Liebau <[email protected]>
Date:   Wed Apr 17 21:59:01 2024 +0200

    Fix vscode launch configs to allow setting breakpoints in the IDE

commit 47fe8e8
Author: Hendrik Liebau <[email protected]>
Date:   Sat Apr 20 21:23:37 2024 +0200

    Add and load React production source maps

    This can be reverted when a React canary version is used that
    includes facebook/react#28881.

commit c8f3798
Author: Hendrik Liebau <[email protected]>
Date:   Sat Apr 20 21:18:35 2024 +0200

    Inline Next.js sources content into source map files

    This avoids a `loadNetworkResource` error in Chrome DevTools when trying
    to set breakpoints in the Next.js sources, for both server and client.

commit c286c02
Author: Tim Neutkens <[email protected]>
Date:   Sat Apr 20 15:45:35 2024 +0200

    Disable ncc cache instead of cache cleaning (#64804)

    `ncc cache clean` is running each time we call `ncc-compiled`. This PR
    removes the cache cleaning and instead just always passes `cache: false`
    to disable the built-in ncc cache.

    <!-- Thanks for opening a PR! Your contribution is much appreciated.
    To make sure your PR is handled as smoothly as possible we request that
    you follow the checklist sections below.
    Choose the right checklist for the change(s) that you're making:

    - Run `pnpm prettier-fix` to fix formatting issues before opening the
    PR.
    - Read the Docs Contribution Guide to ensure your contribution follows
    the docs guidelines:
    https://nextjs.org/docs/community/contribution-guide

    - The "examples guidelines" are followed from our contributing doc
    https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
    - Make sure the linting passes by running `pnpm build && pnpm lint`. See
    https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

    - Related issues linked using `fixes #number`
    - Tests added. See:
    https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
    - Errors have a helpful link attached, see
    https://github.com/vercel/next.js/blob/canary/contributing.md

    - Implements an existing feature request or RFC. Make sure the feature
    request has been accepted for implementation before opening a PR. (A
    discussion must be opened, see
    https://github.com/vercel/next.js/discussions/new?category=ideas)
    - Related issues/discussions are linked using `fixes #number`
    - e2e tests added
    (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
    - Documentation added
    - Telemetry added. In case of a feature if it's used or not.
    - Errors have a helpful link attached, see
    https://github.com/vercel/next.js/blob/canary/contributing.md

    - Minimal description (aim for explaining to someone not on the team to
    understand the PR)
    - When linking to a Slack thread, you might want to share details of the
    conclusion
    - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
    - Add review comments if necessary to explain to the reviewer the logic
    behind a change

    Closes NEXT-
    Fixes #

    -->

    Closes NEXT-3174

commit b914ad8
Author: Zack Tanner <[email protected]>
Date:   Fri Apr 19 18:11:32 2024 -0600

    fix interception route rewrite regex not supporting hyphenated segments (#64805)

    The function we use to generate a string with named parameters to pass
    into `path-to-regexp` currently doesn't properly handle non-word
    characters (namely, for the purposes of this bugfix, hyphens). As a
    result, `pathToRegexp` will convert something like `/foo/:bar-baz` into
    `/^\/foo(?:\/([^\/#\?]+?))-baz[\/#\?]?$/i`, effectively only treating
    the `:foo` as part of the regex capture group and leaving a dangling
    -baz.

    This means using an interception route within a dynamic segment (such as
    `/foo/[bar-baz]`) would not properly trigger the route interception

    Fixes #64766

commit 02e5f65
Author: vercel-release-bot <[email protected]>
Date:   Fri Apr 19 23:23:22 2024 +0000

    v14.3.0-canary.13

commit c1ca6ac
Author: Jeffrey Zutt <[email protected]>
Date:   Sat Apr 20 01:13:58 2024 +0200

    fix: remove traceparent from cachekey should not remove traceparent from original object (#64727)

    I submitted PR #64499 , it got merged, but it contains a mistake.
    I'm terribly sorry about this!

    By removing the traceparent from the cachekey, we mistakenly removed the
    header from the original object.
    Causing the actual request to be executed without the traceparent
    header.

    Creating a cachekey should not alter the original object.

    Flip the arguments for Object.assign

    ---------

    Co-authored-by: Jeffrey <[email protected]>
    Co-authored-by: JJ Kasper <[email protected]>

commit ea0f516
Author: Sean O'Neil <[email protected]>
Date:   Fri Apr 19 15:43:26 2024 -0500

    Update 06-bundle-analyzer.mdx (#64740)

    The[ existing code
    example](https://nextjs.org/docs/app/building-your-application/optimizing/bundle-analyzer)
    generates the following warning when using `--turbo` in the current
    latest version of NextJS (14.2.2):

    ⚠ Webpack is configured while Turbopack is not, which may cause
    problems.
     ⚠ See instructions if you need to configure Turbopack:
      https://nextjs.org/docs/app/api-reference/next-config-js/turbo

    This modification ensures that the bundle analyzer is only applied when
    the user intends to generate a report.

    Fixes # #64739

    ---------

    Co-authored-by: Lee Robinson <[email protected]>
    Co-authored-by: Maxim Svetlakov <[email protected]>
    Co-authored-by: JJ Kasper <[email protected]>

commit cf038a3
Author: Steven Primeaux <[email protected]>
Date:   Fri Apr 19 14:36:25 2024 -0400

    docs: "generateMetadata" to "generateViewport" in doc "generateViewport" (#64795)

    Changed "generateMetadata" to "generateViewport" in
    generate-viewport.mdx

    Co-authored-by: Sam Ko <[email protected]>

commit a0f334c
Author: Kushagra Sharma <[email protected]>
Date:   Sat Apr 20 00:04:21 2024 +0530

    Update index.mdx (#64794)

    Removed a type annotation from a code block

    <!-- Thanks for opening a PR! Your contribution is much appreciated.
    To make sure your PR is handled as smoothly as possible we request that
    you follow the checklist sections below.
    Choose the right checklist for the change(s) that you're making:

    - Run `pnpm prettier-fix` to fix formatting issues before opening the
    PR.
    - Read the Docs Contribution Guide to ensure your contribution follows
    the docs guidelines:
    https://nextjs.org/docs/community/contribution-guide

    - The "examples guidelines" are followed from our contributing doc
    https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
    - Make sure the linting passes by running `pnpm build && pnpm lint`. See
    https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

    - Related issues linked using `fixes #number`
    - Tests added. See:
    https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
    - Errors have a helpful link attached, see
    https://github.com/vercel/next.js/blob/canary/contributing.md

    - Implements an existing feature request or RFC. Make sure the feature
    request has been accepted for implementation before opening a PR. (A
    discussion must be opened, see
    https://github.com/vercel/next.js/discussions/new?category=ideas)
    - Related issues/discussions are linked using `fixes #number`
    - e2e tests added
    (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
    - Documentation added
    - Telemetry added. In case of a feature if it's used or not.
    - Errors have a helpful link attached, see
    https://github.com/vercel/next.js/blob/canary/contributing.md

    - Minimal description (aim for explaining to someone not on the team to
    understand the PR)
    - When linking to a Slack thread, you might want to share details of the
    conclusion
    - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
    - Add review comments if necessary to explain to the reviewer the logic
    behind a change

    Closes NEXT-
    Fixes #

    -->

commit bd6ab04
Author: Tim Neutkens <[email protected]>
Date:   Fri Apr 19 20:26:54 2024 +0200

    Upgrade Turborepo (#64767)

    Upgrade Turborepo to the latest version and enable the new terminal UI
    to dogfood: https://turbo.build/blog/turbo-1-13-0#new-terminal-ui.

    <!-- Thanks for opening a PR! Your contribution is much appreciated.
    To make sure your PR is handled as smoothly as possible we request that
    you follow the checklist sections below.
    Choose the right checklist for the change(s) that you're making:

    - Run `pnpm prettier-fix` to fix formatting issues before opening the
    PR.
    - Read the Docs Contribution Guide to ensure your contribution follows
    the docs guidelines:
    https://nextjs.org/docs/community/contribution-guide

    - The "examples guidelines" are followed from our contributing doc
    https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
    - Make sure the linting passes by running `pnpm build && pnpm lint`. See
    https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

    - Related issues linked using `fixes #number`
    - Tests added. See:
    https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
    - Errors have a helpful link attached, see
    https://github.com/vercel/next.js/blob/canary/contributing.md

    - Implements an existing feature request or RFC. Make sure the feature
    request has been accepted for implementation before opening a PR. (A
    discussion must be opened, see
    https://github.com/vercel/next.js/discussions/new?category=ideas)
    - Related issues/discussions are linked using `fixes #number`
    - e2e tests added
    (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
    - Documentation added
    - Telemetry added. In case of a feature if it's used or not.
    - Errors have a helpful link attached, see
    https://github.com/vercel/next.js/blob/canary/contributing.md

    - Minimal description (aim for explaining to someone not on the team to
    understand the PR)
    - When linking to a Slack thread, you might want to share details of the
    conclusion
    - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
    - Add review comments if necessary to explain to the reviewer the logic
    behind a change

    Closes NEXT-
    Fixes #

    -->

    Closes NEXT-3164
huozhi pushed a commit that referenced this pull request Apr 23, 2024
…rom original object (#64727)

### What?

I submitted PR #64499 , it got merged, but it contains a mistake.
I'm terribly sorry about this!

By removing the traceparent from the cachekey, we mistakenly removed the
header from the original object.
Causing the actual request to be executed without the traceparent
header.

### Why?

Creating a cachekey should not alter the original object.

### How?

Flip the arguments for Object.assign

---------

Co-authored-by: Jeffrey <[email protected]>
Co-authored-by: JJ Kasper <[email protected]>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants