ReviewOS

stacks/stx

Keep client-bundle temporary files unique across JS isolates

#2138
Closed chris opened this 3 days ago ·
3 days ago

HQ's branded native compilation logged an ENOENT while reading .stx/bundle-tmp/out/<hash>-<pid>-15/.stx-client-<hash>-<pid>-15.js. The process continued through the development fallback, so a passing unrelated native test is not proof that the client bundle was complete.

The shared bundler's tempBuildName() combines the content hash, PID and a module-local counter. Separate JS isolates or loaded copies have independent counters; workers share the PID. Two real Node-compatible Bun workers importing the source both return the identical <hash>-<pid>-1. The new deterministic regression fails on the original code (four existing cases pass, one new worker case fails). Loading two independent module copies reproduces the collision too.

Give each build an owned temporary namespace across workers and loaded copies. Keep normal shared-request/cache behavior, actual bundle contents and failure reporting; do not clear HQ caches or suppress the ENOENT. Verify the worker case, concurrent complete bundles, client-bundler tests and normal package release, then consume the published package in HQ.

Observed during https://github.com/stacksjs/hq.training/issues/346; independent of the pointer implementation in https://github.com/stacksjs/stx/issues/2137 and https://github.com/stacksjs/hq.training/issues/339.

3 days ago

Closing as implemented by 5a3ae6c. Each temporary build now includes a fresh UUID, avoiding the shared-PID/independent-counter collision across workers and loaded module copies.

Additional regression coverage landed in 75e437f: packages/stx/test/client-script-bundler/concurrent-bundles.test.ts launches four real workers sharing a project/cache/temp root, bundles a relative import with throwOnFailure enabled, and executes every returned bundle to verify its actual result. The existing cross-worker namespace check also passes; deliberately restoring a shared worker name makes it fail. Full client-bundler checks are included in the 137 passing source checks; types, lint and format pass.

Release status: the fix is tagged for 0.2.754. Its exact-source release gate and macOS signing job have passed, but npm publication is still queued at this check; 0.2.754 is NOT yet verified on npm. This is a source-fix closure, not a claim that HQ has consumed the release. The ongoing release is https://github.com/stacksjs/stx/actions/runs/41089192910 . No replacement tag/version or competing publish was created.

Sign in to comment on this issue.