fix(cli): reject known-bad esbuild versions at build time - #4846
fix(cli): reject known-bad esbuild versions at build time#4846Srinivasan8888 wants to merge 1 commit into
Conversation
…dev#4801) The CLI declares esbuild ^0.23.0, but an npm/pnpm `overrides` entry pinning esbuild across the dependency tree is honoured silently, so the CLI can bundle with a version it has never been tested against. esbuild 0.25.0 has an out-of-bounds source-index regression, fixed in 0.25.1, that drops input `sources` entries while keeping the mapping indices. The resulting chunks are internally inconsistent, and because the worker installs `source-map-support` globally, the first stack trace touching an affected chunk makes `originalPositionFor` throw `Error: No element indexed by N` inside `recordSpanException`. The build itself reports success, so the failure only surfaces in a deployed run. Check `esbuild.version` at the top of `bundleWorker`: - a known-bad version fails the build with a message naming the fixed release and pointing at the `overrides`/`resolutions` entry that is the usual cause - any other out-of-range version warns rather than fails, so users who deliberately move to a newer good release are not blocked Closes triggerdotdev#4801
🦋 Changeset detectedLatest commit: 6bb0237 The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Hi @Srinivasan8888, thanks for your interest in contributing! This project requires that pull request authors are vouched, and you are not in the list of vouched users. This PR will be closed automatically. See https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md for more details. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
WalkthroughThe CLI now checks the resolved esbuild version before bundling. Known-bad versions produce an error and stop the build. Other versions outside the tested range produce a warning. The new checker defines the supported range and version issue type. Tests cover supported, known-bad, fixed, out-of-range, and unparsable versions. A Changeset documents the patch release. ✨ Finishing Touches🧪 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 |
Problem
The CLI declares
esbuild ^0.23.0, but a package manageroverrides/resolutionsentry is honoured silently, so the CLI can bundle with a versionit has never been tested against.
esbuild 0.25.0 has an out-of-bounds source-index regression, fixed in 0.25.1,
that drops input
sourcesentries while keeping the mapping indices. Theresulting chunks are internally inconsistent. Because the worker installs
source-map-supportglobally (entryPoints/managed-run-worker.js), the firststack trace touching an affected chunk makes
originalPositionForthrowError: No element indexed by NinsiderecordSpanException(otel/utils.ts).The build itself reports success, so the failure only surfaces in a deployed run.
Change
Check
esbuild.version— the version actually resolved, not the declared range —at the top of
bundleWorker:and pointing at the
overridesentry that is the usual causedeliberately move to a newer good release are not blocked
The known-bad list is a small table in
esbuildVersion.ts, so future entries areone line.
Cost/benefit
This adds a gate to every
deployanddevbuild, so the risk is a falsepositive blocking a legitimate build. That is why only versions with a known
output-corrupting defect hard-fail; everything else warns. The benefit is that
the failure mode it replaces is a runtime crash inside a deployed task with a
message (
No element indexed by 6) that gives no hint the cause is adependency pin.
Tests
packages/cli-v3/src/build/esbuildVersion.test.ts— 5 tests: in-range accepted,0.25.0 rejected with the fix version named, 0.25.1 not rejected, out-of-range
warns without failing, unparseable version ignored.
Note: the cli-v3 suite has 5 failing test files and 1 failing test on unmodified
main(snapshot.test.tsand four "No test suite found" files). I baselinedbefore and after — this branch adds no new failures.
refs #4801