Repository navigation
test(core): build a private bundle for the worker-event forwarding test - #59
Merged
Merged
Conversation
The test imported packages/core/dist/index.js, which `pnpm build` (tsup, clean: true) deletes and rewrites. A build running alongside the test could remove the bundle mid-import: ERR_MODULE_NOT_FOUND, 2 failures in 50 runs with build and lint looping in parallel. The test now builds its own copy into a fresh directory under node_modules (so bare imports resolve) and removes it afterwards. 0 failures in 50 runs under the same load. Closes #58 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EmiChUUtLdjbg6mNzKqVep Signed-off-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What and why
Closes #58.
forwards real workspace worker events without serializing the callback(packages/core/src/check/progress.test.ts) imported the sharedpackages/core/dist/index.js.pnpm buildruns tsup withclean: true, which deletes and rewritesdist/. A build running at the same time as the test (the PR #54 case: lint and build in parallel) can remove the bundle while the child process imports it.This was not a timing problem. There are no sleeps or fixed timeouts, and event order is fine: progress messages and the result share one worker port, so they arrive in order. Both failures I reproduced are the same
ERR_MODULE_NOT_FOUND:The test exists to run the built worker (
dist/worker.js), which the source-based suite never runs, so it still needs a real build. It now builds its own copy:--no-dts --no-sourcemap(about 1 s), into a freshmkdtempdirectory underpackages/core/node_modules/. Being inside the package lets the bundle's bare imports (ts-morph, …) resolve.afterAll.No published code changes, so there is no changeset.
How it was verified
Each loop is 50 runs of
vitest run src/check/progress.test.ts -t 'forwards real workspace'on a 4-core machine:pnpm buildandpnpm lintlooping in parallelERR_MODULE_NOT_FOUNDAt a 4% rate, 0 failures in 50 runs could still happen by chance (about 13%), so I also checked the mechanism directly. With
packages/core/distdeleted, the original test fails with the same error and the new one passes.Checklist
dist/removed: the old test fails, the new one passes)pnpm lint && pnpm typecheck && pnpm testpass (core 927 passed / 15 skipped, cli 350 passed)@uptide/core)Not changed here: other tests that read a package's
dist/(for examplepackages/cli/src/list-registry.test.tsandtelemetry/sender.test.ts) could hit the same race when a build runs alongside them.🤖 Generated with Claude Code
https://claude.ai/code/session_01EmiChUUtLdjbg6mNzKqVep
Generated by Claude Code