Skip to content

test - #565

Closed
Ryan-Millard wants to merge 2 commits into
devfrom
test-python-failure
Closed

test#565
Ryan-Millard wants to merge 2 commits into
devfrom
test-python-failure

Conversation

@Ryan-Millard

@Ryan-Millard Ryan-Millard commented Aug 18, 2026

Copy link
Copy Markdown
Owner

This is a test for #562's failed workflow run. @coderabbitai, please don't review this.

…vailable

The CJS build (dist/node/img2num.cjs) crashed on Node < 22.12 instead of
converting. Two causes:

1. src/target/node/webgpu.js statically imported the ESM-only `webgpu`
   package. Rolldown compiles static imports of externals in the CJS
   output to a top-level require("webgpu"), which throws ERR_REQUIRE_ESM
   on Node < 22.12 (Node >= 22.12 supports require(esm), masking the bug
   in dev). The import is now dynamic, which Rolldown preserves as a real
   import() in CJS output.

2. When the webgpu import rejects (ERR_REQUIRE_ESM, or the optional
   dependency not installed, e.g. --ignore-optional), initWasmModule
   logged "should fall back to CPU" but initialized the wasm anyway with
   no globalThis.navigator. The Emscripten glue dereferences `navigator`
   unconditionally, so the conversion died with "navigator is not
   defined" instead of falling back. The catch block now installs a stub
   navigator.gpu whose requestAdapter() resolves null, routing the glue
   to its CPU path.

Adds a generateBundle guard (cjsWebgpuGuard) for the node-cjs target
that fails the build if any emitted chunk contains an executable
require("webgpu"), so a future bundler change cannot silently lower the
dynamic import back into the broken form (same class of regression as
the v0.4.0 wasm URL inlining).

Verified: guard fails the build when the static import is reintroduced;
with node_modules/webgpu removed, both ESM and CJS console examples
fall back to CPU and produce the SVG; with webgpu present, the CJS
entry now initializes the GPU identically to ESM.
@Ryan-Millard
Ryan-Millard changed the base branch from main to dev August 18, 2026 16:16
@coderabbitai

This comment was marked as outdated.

@Ryan-Millard

Ryan-Millard commented Aug 18, 2026

Copy link
Copy Markdown
Owner Author

This PR proves that the failures of #562's CI runs are not already in dev... I wonder what the problem is.


Very strange errors in the PR that seem to have been resolved now: https://github.com/Ryan-Millard/Img2Num/actions/runs/31968459437/job/95780256675?pr=562

Either a GitHub issue or something worth a deeper look. Either way, a proper diagnosis is required.

Repository owner deleted a comment from github-actions Bot Aug 18, 2026
Comment-stripping with a regex mis-lexes double forward-slash
nside string literals (URLs) and could hide an executable require
of webgpu. The guard now matches raw chunk code; the source JSDoc
no longer contains the matchable pattern, so any hit is executable.
Addresses CodeRabbit review on the guard's false-negative case.
@github-actions github-actions Bot added the js/ts label Aug 18, 2026
@Ryan-Millard
Ryan-Millard force-pushed the test-python-failure branch 2 times, most recently from d750c88 to 8cabd9f Compare August 18, 2026 17:27
@Ryan-Millard
Ryan-Millard deleted the test-python-failure branch August 18, 2026 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant