GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: hash initial chunks before runtime chunks by davidmurdoch · Pull Request #20711 · webpack/webpack

Conversation

@davidmurdoch

@davidmurdoch davidmurdoch commented Mar 26, 2026

Copy link
Copy Markdown

Fixes #20710

Summary

  • hash initial chunks before runtime chunks in Compilation.createHash()
  • add a watch regression test that reproduces the stale RealContentHashPlugin reference error

Testing

  • node node_modules/eslint/bin/eslint.js lib/Compilation.js test/RealContentHashPlugin.test.js
  • yarn test:base --runInBand --runTestsByPath test/Watch.test.js test/RealContentHashPlugin.test.js

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@davidmurdoch
fix: hash initial chunks before runtime chunks
1818881
@changeset-bot

changeset-bot Bot commented Mar 26, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f392dee

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

This PR includes changesets to release 1 package
Name Type
webpack Patch

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@linux-foundation-easycla

linux-foundation-easycla Bot commented Mar 26, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: alexander-akait / name: Alexander Akait (f392dee)
  • ✅ login: davidmurdoch / name: David Murdoch (1818881, 73834df, de13ec9)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

alexander-akait
alexander-akait requested changes Mar 26, 2026
View reviewed changes

@alexander-akait alexander-akait left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Please use integration tests, we have watchCases and hotCases, unittests are useless

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

davidmurdoch reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@davidmurdoch davidmurdoch mentioned this pull request Mar 26, 2026
RealContentHashPlugin watch rebuild can keep stale runtime chunk filename hashes #20710
Closed
@davidmurdoch
test: switch hash-order regression to watch case
73834df
@davidmurdoch

davidmurdoch commented Mar 26, 2026

Copy link
Copy Markdown
Author

Is the watch case i added okay?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

alexander-akait
alexander-akait reviewed Mar 26, 2026
View reviewed changes
Comment thread test/watchCases/cache/stale-runtime-chunk-filename-map/0/service-worker.js
expect(currentChunkFile).not.toBe(STATE.previousChunkFile);
}

expect(serviceWorkerSource).toContain(currentChunkFile);

@alexander-akait alexander-akait Mar 26, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think we don't need it to compare content, it is useless too, just test shared value, also test itself without errors and warnings means that we fixed the problem

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@alexander-akait alexander-akait Mar 26, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Just use import mod from "./shared.js" and expect(mod).toBe("__SHARED__") and in the next expect(mod).toBe("__SHARED__CHANGED")

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@davidmurdoch davidmurdoch Mar 27, 2026

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

a simple test like:

import { sharedValue } from "./shared.js";

it("should update the runtime chunk filename map on rebuild", () => {
	expect(sharedValue).toBe(
		WATCH_STEP === "0" ? "__SHARED__" : "__SHARED__CHANGED"
	);
});

does not catch the bug if the fix in this PR is reverted. The emitted service-worker.js content check is what actually fails before the fix and passes after.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@davidmurdoch davidmurdoch Mar 27, 2026

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

i've updated the test with a clarifying comment.

please feel free to edit the code yourself if you know a better way!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

alexander-akait reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
davidmurdoch and others added 2 commits March 26, 2026 20:50
@davidmurdoch
add comment clarifying why the assertion is needed
de13ec9
@alexander-akait
test: small refactor
f392dee
@alexander-akait
alexander-akait marked this pull request as ready for review March 27, 2026 11:11
Copilot AI review requested due to automatic review settings March 27, 2026 11:11
Copilot started reviewing on behalf of alexander-akait March 27, 2026 11:12
View session
@codspeed

codspeed Bot commented Mar 27, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Merging this PR will improve performance by 25.82%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 143 untouched benchmarks

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ Memory benchmark "css-modules", scenario '{"name":"mode-production","mode":"production"}' 8.5 MB 6.8 MB +25.82%

Comparing davidmurdoch:fix/real-content-hash-watch-order (f392dee) with main (32a30c2)

Open in CodSpeed
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Copilot AI reviewed Mar 27, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a watch-mode caching bug where runtime chunks could embed stale filename/hash references by ensuring initial chunks are hashed before runtime chunks during Compilation.createHash().

Changes:

  • Adjust chunk hashing order in Compilation.createHash() to hash initial chunks before runtime chunks.
  • Add a new watch regression test case covering runtime chunk filename map updates across rebuilds.
  • Add a changeset entry documenting the patch change.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lib/Compilation.js Reorders chunk hashing so non-runtime (incl. initial) chunks are hashed before runtime chunks.
test/watchCases/cache/stale-runtime-chunk-filename-map/webpack.config.js Adds a dedicated watch-mode repro config with splitChunks + memory cache to exercise runtime filename mapping updates.
test/watchCases/cache/stale-runtime-chunk-filename-map/test.config.js Exposes a helper to read the emitted service worker asset for runtime-reference assertions.
test/watchCases/cache/stale-runtime-chunk-filename-map/0/service-worker.js Asserts that the runtime output references the current hashed shared chunk filename on each watch step.
test/watchCases/cache/stale-runtime-chunk-filename-map/0/offscreen.js Provides a second entry to force a shared initial chunk used by multiple entrypoints.
test/watchCases/cache/stale-runtime-chunk-filename-map/0/shared.js Baseline shared module for step 0.
test/watchCases/cache/stale-runtime-chunk-filename-map/1/shared.js Modified shared module for step 1 to force a rebuild and new chunk hash/filename.
.changeset/public-horses-visit.md Records the behavior change as a patch-level release note.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread test/watchCases/cache/stale-runtime-chunk-filename-map/webpack.config.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@alexander-akait

alexander-akait commented Mar 27, 2026

Copy link
Copy Markdown
Member

/cc @xiaoxiaojx Can you take a look at this, looks like something wrong with hashes, after changing of order, esm-async-chunks-hmr and node-async-chunks-hmr stop working, looks like we need more complex logic to fix both edge cases, thanks

davidmurdoch reacted with eyes emoji
All reactions
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@xiaoxiaojx

xiaoxiaojx commented Mar 27, 2026

Copy link
Copy Markdown
Member

I’ll take a look — this seems a bit tricky. There’s a circular here.

Related issue: #19439, PR: #19570.

alexander-akait reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@alexander-akait

alexander-akait commented Mar 27, 2026

Copy link
Copy Markdown
Member

@xiaoxiaojx Yeah, you are right, maybe we can track circuital situations, no rush, but will be great to look at this

davidmurdoch reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@davidmurdoch

davidmurdoch commented Mar 27, 2026

Copy link
Copy Markdown
Author

Oh wow. That is tricky!

Feel free to close this one, I don't mind.

And ping me if you want to help testing solutions.

xiaoxiaojx reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@xiaoxiaojx xiaoxiaojx mentioned this pull request Mar 28, 2026
fix: hash entry chunks after runtime chunks to prevent stale hash references #20724
Merged
@alexander-akait alexander-akait closed this in #20724 Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@alexander-akait alexander-akait alexander-akait requested changes
Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

RealContentHashPlugin watch rebuild can keep stale runtime chunk filename hashes

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@davidmurdoch @alexander-akait @xiaoxiaojx
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.