Added tsx loading for bree job workers under Vitest#28048
Conversation
- the unified watch-mode change registers tsx in ghost/core's Vitest worker
via require('tsx/cjs'); bree runs "offloaded" jobs in their own worker
threads, which can't see that hook and so can't require()/import Ghost's
.ts server source
- a new Worker inherits the process.execArgv snapshot taken at process
startup — mutating the live array does not propagate — so the fix adds
tsx's loader to execArgv and patches Worker to pass the live execArgv
explicitly to every spawned worker
- no current test hits this (no unit test offloads a .ts-loading job), but
the integration and e2e suites run jobs heavily; this unblocks migrating
them off Mocha
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThis PR adds Vitest setup code to ensure TypeScript sources can be loaded within worker threads. The change conditionally appends the tsx CommonJS loader to Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Extends the tsx scoping from the unified watch-mode work (#28038) so bree job workers can load Ghost's
.tsserver source under Vitest.Background
#28038 scoped tsx to
ghost/core's Vitest workers viarequire('tsx/cjs')(instead of a globalNODE_OPTIONS='--import tsx', which broke the app projects). That hook is registered only in the test's own thread — it doesn't reach the worker threads bree spawns for "offloaded" jobs, so a job worker requiring.tsserver source fails withCannot find module.This surfaced in the Phase A spike for the Mocha retirement:
test/integration/jobs/update-check.test.jsfailed because the update-check job runs in a bree worker.The fix
A
Workerinherits theprocess.execArgvsnapshot taken at process startup — mutating the live array does not propagate to spawned workers. So the fix:process.execArgv.worker_threads.Workerso every spawned worker is passed the liveexecArgvexplicitly.Both are scoped to
ghost/core's Vitest setup file — no effect on the app projects.Why now
No current test hits this — no unit test offloads a
.ts-loading job. But the integration and e2e suites run jobs heavily, so this unblocks migrating them off Mocha.Testing
test/integration/jobs/update-check.test.js(which spawns a bree job worker) now passes under Vitest.ghost/coreunit suite green — 550 files / 6573 tests — confirming theWorkerpatch causes no regression.