Repository navigation
fix(electron): normalize hashed standalone externals - #7353
diegosouzapw merged 2 commits into
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Thanks for tracking this down — this lines up exactly with #7346 (macOS Electron I verified locally in an isolated worktree: both new regression tests pass, the full One tiny nit (non-blocking, won't hold up the merge): the inventory-table comment at the top of Planning to merge this as-is. Will also link it to close #7346. |
1e29b5c
into
cheaper-inference:release/v3.8.49
|
Merged into |
…ce#7353) * fix(electron): normalize hashed standalone externals * chore(release): add cheaper-inference#7353 changelog fragment
…ce#7353) * fix(electron): normalize hashed standalone externals * chore(release): add cheaper-inference#7353 changelog fragment
…one bundles
The standalone tracer emits externalized packages as REAL directories named
`playwright-core-<16hex>`, but the Turbopack server runtime asks for the BARE
specifier at request time: the externals chunk does
`await ctx.externalImport("playwright-core")`, and that literal carries no hash
for patchTurbopackChunks() to strip. Node then walks up from
`<outDir>/<relDistDir>/server/chunks/`, finds only the hashed sibling, and throws
ERR_MODULE_NOT_FOUND.
The failure is lazy and route-shaped, so it reads like a data bug. The externals
chunk only loads when a route first reaches the module, so the server boots
cleanly and only the affected route 500s — with an EMPTY body, because the route
module never evaluates. On a Windows Electron build `GET /api/providers`
returned 500/empty, which the dashboard's `safeJson()` silently degrades to `[]`,
blanking /dashboard/providers and /dashboard/combos while /dashboard/models (no
/api/providers dependency) kept working.
Each existing repair misses it, and the misses compose:
- materializeBundledSymlinks (cheaper-inference#6724/cheaper-inference#6594) only touches symlinks; its
`if (!stat.isSymbolicLink()) continue;` skips a real hashed directory.
- patchTurbopackChunks (cheaper-inference#7353) strips the hash off the reference, which is what
creates the bare-name requirement in the first place.
- repairEmptyExternalPackageDirs (cheaper-inference#9913/cheaper-inference#7346) only overlays dirs that already
EXIST but are hollow, and needs the package in the source node_modules. Here
the bare dir does not exist at all and the dependency is Turbopack-only, so
neither precondition holds.
Add materializeHashedModuleAliases() and run it unconditionally as step 8, after
materializeBundledSymlinks so hashed symlinks are already real directories and
can serve as copy sources. It keeps both names (so a hashed `require()` still
resolves), never clobbers an already-traced bare package, skips symlinks, and is
idempotent.
Related: cheaper-inference#7346
Summary
Fixes the Electron packaging path that left Turbopack-hashed external imports such as
ws-a972e7ffa40ff725in server instrumentation chunks.assembleStandalonealready haspatchTurbopackChunksfor this exact normalization and the npm prepublish flow enables it. The Electron staging flow did not, so the packaged app copied canonicalnode_modules/wsbut attempted to import the non-existent hashed name at startup.This enables the existing normalization step for Electron builds and adds regression coverage for both the package-name rewrite and the Electron assembly wiring.
Validation
node --import tsx/esm --test --test-name-pattern "patchTurbopackChunks restores canonical external package names|electron standalone assembly normalizes Turbopack hashed external imports" tests/unit/build/assemble-standalone.test.ts tests/unit/electron-packaging.test.tsnpx prettier --check scripts/build/prepare-electron-standalone.mjs tests/unit/build/assemble-standalone.test.ts tests/unit/electron-packaging.test.tsnpx eslint tests/unit/build/assemble-standalone.test.ts tests/unit/electron-packaging.test.ts --no-error-on-unmatched-pattern --suppressions-location config/quality/eslint-suppressions.jsongit diff --checkThe complete
assemble-standalone.test.tssuite has an existing Windows-only path failure in its unrelatedstandalone-server-ws.mjstest: it derives afile:URL with.pathname, producingF:\\F:\\.... The selected new regression and Electron packaging test both pass.Scope
No provider behavior, route handling, or bundled dependency list changes. The staging step now rewrites only the erroneous hash suffixes before
electron-buildercopies the standalone bundle.