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 — test: make them stable by alexander-akait · Pull Request #20898 · webpack/webpack

test: make them stable #20898

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.

Sign up for GitHub

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

Merged
alexander-akait merged 5 commits into main from claude/improve-macos-ci-performance-J0ne8
Apr 30, 2026

Uh oh!

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

Merged

test: make them stable #20898

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
5 commits
Select commit Hold shift + click to select a range
59ce11b
test: fix prefetch-preload-module-jsonp race on old Node
alexander-akait Apr 30, 2026
21d48e6
test: convert prefetch-preload to async/await
alexander-akait Apr 30, 2026
881900d
test: silence dangling rejection in manifest-plugin index-2
alexander-akait Apr 30, 2026
7c88d80
test: silence chunkLoadTimeout from dangling CSS chunk loads
alexander-akait Apr 30, 2026
b91111d
fix: prevent unhandled rejection from prefetch trigger runtime
alexander-akait Apr 30, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

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

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

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

Diff view
Diff view

There are no files selected for viewing

5 changes: 5 additions & 0 deletions 5 .changeset/prefetch-trigger-unhandled-rejection.md
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"webpack": patch
---

Silence unhandled rejection from the prefetch trigger when chunk loading fails. The `ensureChunkHandlers.prefetch` runtime created `Promise.all(promises).then(...)` whose result is discarded by `__webpack_require__.e`. If chunk loading rejected (e.g. `chunkLoadTimeout`), that dangling chain produced an unhandled rejection. Prefetch is best-effort, so a no-op rejection handler is now attached.
5 changes: 4 additions & 1 deletion 5 lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@ class ChunkPrefetchTriggerRuntimeModule extends RuntimeModule {
`${
RuntimeGlobals.ensureChunkHandlers
}.prefetch = ${runtimeTemplate.expressionFunction(
// Prefetch is best-effort; silence rejections so a failed chunk
// load (e.g. chunkLoadTimeout) doesn't surface as an unhandled
// rejection through this dangling Promise.all chain.
`Promise.all(promises).then(${runtimeTemplate.basicFunction(
"",
body
)})`,
)}, ${runtimeTemplate.basicFunction("", "")})`,
"chunkId, promises"
)};`
])
Expand Down
6 changes: 5 additions & 1 deletion 6 test/configCases/plugins/manifest-plugin/index-2.js
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import "./style.css";
import "./dependency.js";
import url from "../../asset-modules/_images/file.png";

import(/* webpackChunkName: 'file' */ "./file.txt?foo");
// The dynamic import is here so ManifestPlugin emits a `file.txt?foo` entry;
// it isn't awaited (CJS top-level), and the JSONP runtime never resolves it
// in this harness. Catch so a stray rejection on old Node can't bubble up
// into the test as an unhandled rejection.
import(/* webpackChunkName: 'file' */ "./file.txt?foo").catch(() => {});
Comment thread
alexander-akait marked this conversation as resolved.
Resolved

Uh oh!

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


new URL("./file.txt", import.meta.url);
new URL("./public/other.txt", import.meta.url);
Expand Down
118 changes: 64 additions & 54 deletions 118 test/configCases/web/prefetch-preload-module-jsonp/index.mjs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
__webpack_nonce__ = "nonce";
__webpack_public_path__ = "https://example.com/public/path/";

it("should prefetch and preload child chunks on chunk load", () => {
it("should prefetch and preload child chunks on chunk load", async () => {
let link, script;

expect(document.head._children).toHaveLength(3);
Expand Down Expand Up @@ -64,76 +64,86 @@ it("should prefetch and preload child chunks on chunk load", () => {
expect(link.getAttribute("nonce")).toBe("nonce");
expect(link.crossOrigin).toBe("anonymous");

// Run the script
import(/* webpackIgnore: true */ "./chunk1.js");
// Run the script — `await` is required: on older V8 the host import
// callback for `import(webpackIgnore)` is queued as a microtask, so
// without awaiting, `script.onload()` would fire before the chunk's
// `webpackChunk.push` runs and the JSONP runtime would reject with
// "Loading chunk chunk1 failed".
await import(/* webpackIgnore: true */ "./chunk1.js");

script.onload();

return promise.then(() => {
expect(document.head._children).toHaveLength(8);
await promise;

// Test prefetching for chunk1-c and chunk1-a in this order
link = document.head._children[6];
expect(link._type).toBe("link");
expect(link.rel).toBe("prefetch");
expect(link.as).toBe("script");
expect(link.href).toBe("https://example.com/public/path/chunk1-c.js");
expect(link.crossOrigin).toBe("anonymous");
expect(document.head._children).toHaveLength(8);

link = document.head._children[7];
expect(link._type).toBe("link");
expect(link.rel).toBe("prefetch");
expect(link.as).toBe("script");
expect(link.href).toBe("https://example.com/public/path/chunk1-a.js");
expect(link.crossOrigin).toBe("anonymous");
// Test prefetching for chunk1-c and chunk1-a in this order
link = document.head._children[6];
expect(link._type).toBe("link");
expect(link.rel).toBe("prefetch");
expect(link.as).toBe("script");
expect(link.href).toBe("https://example.com/public/path/chunk1-c.js");
expect(link.crossOrigin).toBe("anonymous");

link = document.head._children[7];
expect(link._type).toBe("link");
expect(link.rel).toBe("prefetch");
expect(link.as).toBe("script");
expect(link.href).toBe("https://example.com/public/path/chunk1-a.js");
expect(link.crossOrigin).toBe("anonymous");

const promise2 = import(
Comment thread
/* webpackChunkName: "chunk1", webpackPrefetch: true */ "./chunk1.js"
);

const promise2 = import(
/* webpackChunkName: "chunk1", webpackPrefetch: true */ "./chunk1.js"
);
// Loading chunk1 again should not trigger prefetch/preload
expect(document.head._children).toHaveLength(8);

// Loading chunk1 again should not trigger prefetch/preload
expect(document.head._children).toHaveLength(8);
const promise3 = import(/* webpackChunkName: "chunk2" */ "./chunk2.js");

const promise3 = import(/* webpackChunkName: "chunk2" */ "./chunk2.js");
expect(document.head._children).toHaveLength(9);

expect(document.head._children).toHaveLength(9);
// Test normal script loading
script = document.head._children[8];
expect(script._type).toBe("script");
expect(script.src).toBe("https://example.com/public/path/chunk2.js");
expect(script.getAttribute("nonce")).toBe("nonce");
expect(script.crossOrigin).toBe("anonymous");
expect(script.onload).toBeTypeOf("function");

// Test normal script loading
script = document.head._children[8];
expect(script._type).toBe("script");
expect(script.src).toBe("https://example.com/public/path/chunk2.js");
expect(script.getAttribute("nonce")).toBe("nonce");
expect(script.crossOrigin).toBe("anonymous");
expect(script.onload).toBeTypeOf("function");
// Run the script — see note above about awaiting before script.onload().
await import(/* webpackIgnore: true */ "./chunk2.js");

// Run the script
import(/* webpackIgnore: true */ "./chunk2.js");
script.onload();

script.onload();
await promise3;

return promise3.then(() => {
// Loading chunk2 again should not trigger prefetch/preload as it's already prefetch/preloaded
expect(document.head._children).toHaveLength(8);
// Loading chunk2 again should not trigger prefetch/preload as it's already prefetch/preloaded
expect(document.head._children).toHaveLength(8);

const promise4 = import(/* webpackChunkName: "chunk1-css" */ "./chunk1.css");
// chunk1-css / chunk2-css each install a <link rel="stylesheet"> AND a
// <script> for the JS half. We never invoke script.onload() for those, so
// the JSONP runtime arms a chunkLoadTimeout (120s) that would fire mid-way
// through later tests on slow runners. Swallow the eventual rejection.
const promise4 = import(/* webpackChunkName: "chunk1-css" */ "./chunk1.css");
Comment thread
github-code-quality[bot] marked this conversation as resolved.
Fixed

Uh oh!

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

promise4.catch(() => {});

expect(document.head._children).toHaveLength(10);
expect(document.head._children).toHaveLength(10);

link = document.head._children[8];
expect(link._type).toBe("link");
expect(link.rel).toBe("stylesheet");
expect(link.href).toBe("https://example.com/public/path/chunk1-css.css");
expect(link.crossOrigin).toBe("anonymous");
link = document.head._children[8];
expect(link._type).toBe("link");
expect(link.rel).toBe("stylesheet");
expect(link.href).toBe("https://example.com/public/path/chunk1-css.css");
expect(link.crossOrigin).toBe("anonymous");

const promise5 = import(/* webpackChunkName: "chunk2-css", webpackPrefetch: true */ "./chunk2.css");
const promise5 = import(/* webpackChunkName: "chunk2-css", webpackPrefetch: true */ "./chunk2.css");
Comment thread
github-code-quality[bot] marked this conversation as resolved.
Fixed

Uh oh!

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

promise5.catch(() => {});

expect(document.head._children).toHaveLength(12);
expect(document.head._children).toHaveLength(12);

link = document.head._children[10];
expect(link._type).toBe("link");
expect(link.rel).toBe("stylesheet");
expect(link.href).toBe("https://example.com/public/path/chunk2-css.css");
expect(link.crossOrigin).toBe("anonymous");
});
});
link = document.head._children[10];
expect(link._type).toBe("link");
expect(link.rel).toBe("stylesheet");
expect(link.href).toBe("https://example.com/public/path/chunk2-css.css");
expect(link.crossOrigin).toBe("anonymous");
});
112 changes: 59 additions & 53 deletions 112 test/configCases/web/prefetch-preload/index.js
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
__webpack_nonce__ = "nonce";
__webpack_public_path__ = "https://example.com/public/path/";

it("should prefetch and preload child chunks on chunk load", () => {
it("should prefetch and preload child chunks on chunk load", async () => {
let link, script;

expect(document.head._children).toHaveLength(3);
Expand Down Expand Up @@ -72,72 +72,78 @@ it("should prefetch and preload child chunks on chunk load", () => {

script.onload();

return promise.then(() => {
expect(document.head._children).toHaveLength(8);
await promise;

// Test prefetching for chunk1-c and chunk1-a in this order
link = document.head._children[6];
expect(link._type).toBe("link");
expect(link.rel).toBe("prefetch");
expect(link.as).toBe("script");
expect(link.href).toBe("https://example.com/public/path/chunk1-c.js");
expect(link.charset).toBe("utf-8");
expect(link.crossOrigin).toBe("anonymous");
expect(document.head._children).toHaveLength(8);

link = document.head._children[7];
expect(link._type).toBe("link");
expect(link.rel).toBe("prefetch");
expect(link.as).toBe("script");
expect(link.href).toBe("https://example.com/public/path/chunk1-a.js");
expect(link.crossOrigin).toBe("anonymous");
// Test prefetching for chunk1-c and chunk1-a in this order
link = document.head._children[6];
expect(link._type).toBe("link");
expect(link.rel).toBe("prefetch");
expect(link.as).toBe("script");
expect(link.href).toBe("https://example.com/public/path/chunk1-c.js");
expect(link.charset).toBe("utf-8");
expect(link.crossOrigin).toBe("anonymous");

link = document.head._children[7];
expect(link._type).toBe("link");
expect(link.rel).toBe("prefetch");
expect(link.as).toBe("script");
expect(link.href).toBe("https://example.com/public/path/chunk1-a.js");
expect(link.crossOrigin).toBe("anonymous");

const promise2 = import(
Comment thread
/* webpackChunkName: "chunk1", webpackPrefetch: true */ "./chunk1"
);

const promise2 = import(
/* webpackChunkName: "chunk1", webpackPrefetch: true */ "./chunk1"
);
// Loading chunk1 again should not trigger prefetch/preload
expect(document.head._children).toHaveLength(8);

// Loading chunk1 again should not trigger prefetch/preload
expect(document.head._children).toHaveLength(8);
const promise3 = import(/* webpackChunkName: "chunk2" */ "./chunk2");

const promise3 = import(/* webpackChunkName: "chunk2" */ "./chunk2");
expect(document.head._children).toHaveLength(9);

expect(document.head._children).toHaveLength(9);
// Test normal script loading
script = document.head._children[8];
expect(script._type).toBe("script");
expect(script.src).toBe("https://example.com/public/path/chunk2.js");
expect(script.getAttribute("nonce")).toBe("nonce");
expect(script.crossOrigin).toBe("anonymous");
expect(script.onload).toBeTypeOf("function");

// Test normal script loading
script = document.head._children[8];
expect(script._type).toBe("script");
expect(script.src).toBe("https://example.com/public/path/chunk2.js");
expect(script.getAttribute("nonce")).toBe("nonce");
expect(script.crossOrigin).toBe("anonymous");
expect(script.onload).toBeTypeOf("function");
// Run the script
__non_webpack_require__("./chunk2.js");

// Run the script
__non_webpack_require__("./chunk2.js");
script.onload();

script.onload();
await promise3;

return promise3.then(() => {
// Loading chunk2 again should not trigger prefetch/preload as it's already prefetch/preloaded
expect(document.head._children).toHaveLength(8);
// Loading chunk2 again should not trigger prefetch/preload as it's already prefetch/preloaded
expect(document.head._children).toHaveLength(8);

const promise4 = import(/* webpackChunkName: "chunk1-css" */ "./chunk1.css");
// chunk1-css / chunk2-css each install a <link rel="stylesheet"> AND a
// <script> for the JS half. We never invoke script.onload() for those, so
// the JSONP runtime arms a chunkLoadTimeout (120s) that would fire mid-way
// through later tests on slow runners. Swallow the eventual rejection.
const promise4 = import(/* webpackChunkName: "chunk1-css" */ "./chunk1.css");
Comment thread
github-code-quality[bot] marked this conversation as resolved.
Fixed

Uh oh!

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

promise4.catch(() => {});

expect(document.head._children).toHaveLength(10);
expect(document.head._children).toHaveLength(10);

link = document.head._children[8];
expect(link._type).toBe("link");
expect(link.rel).toBe("stylesheet");
expect(link.href).toBe("https://example.com/public/path/chunk1-css.css");
expect(link.crossOrigin).toBe("anonymous");
link = document.head._children[8];
expect(link._type).toBe("link");
expect(link.rel).toBe("stylesheet");
expect(link.href).toBe("https://example.com/public/path/chunk1-css.css");
expect(link.crossOrigin).toBe("anonymous");

const promise5 = import(/* webpackChunkName: "chunk2-css", webpackPrefetch: true */ "./chunk2.css");
const promise5 = import(/* webpackChunkName: "chunk2-css", webpackPrefetch: true */ "./chunk2.css");
Comment thread
github-code-quality[bot] marked this conversation as resolved.
Fixed

Uh oh!

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

promise5.catch(() => {});

expect(document.head._children).toHaveLength(12);
expect(document.head._children).toHaveLength(12);

link = document.head._children[10];
expect(link._type).toBe("link");
expect(link.rel).toBe("stylesheet");
expect(link.href).toBe("https://example.com/public/path/chunk2-css.css");
expect(link.crossOrigin).toBe("anonymous");
});
});
link = document.head._children[10];
expect(link._type).toBe("link");
expect(link.rel).toBe("stylesheet");
expect(link.href).toBe("https://example.com/public/path/chunk2-css.css");
expect(link.crossOrigin).toBe("anonymous");
});
Loading
Oops, something went wrong.

Uh oh!

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

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.