Repository navigation
[cli] Fix server stack traces pointing at the wrong source on Node 24.22+ - #52102
Conversation
….22+ `@expo/require-utils` writes each server bundle's source map to a temporary file and removes it right after `_compile`, assuming Node parses the map eagerly. Since Node 24.22.0, Node only records the map's path during `_compile` and reads the file on the first lookup, after it's gone, so no server bundle (API routes, rendering, data loaders) has a Node-level source map. Look the map up before removing the file. Frames Node can't map fall back to Metro's /symbolicate, which rebuilds the bundle from the frame's URL. A data loader bundle's URL matched its entry's full bundle, so Metro mapped loader errors against the full bundle and pointed them into react/jsx-runtime.js. Mark loader bundles with `transform.isLoaderBundle` in their URL. This is why `start-server-stack-traces.test.ts` failed on every CI run that got Node 24.22.x and passed on every run that got 24.21.0.
|
Bug fix · 80% confidence Preliminary assessment based on the supplied report; claims have not been verified.
|
|
Subscribed to pull request
Generated by CodeMention |
|
@expo-bot verify |
|
Outcome: pass @brentvatne Result: reproduced and confirmed. On base Reporter: Nothing is needed from you. The Node regression is wider than the PR says. Node's changelog puts the same change in Node 26.9.0, and Node 26.12.1 also loses the source map in my test. You can add that to the Maintainer: The PR is correct as written. Unit tests, typecheck, and lint pass. The new Environment and versions
E2E tally: start-server-stack-traces.test.tsCommand:
For each single-change arm, I checked the built output before the runs:
The base failure on Node 24.22.1 is the same failure the PR describes. The loader frame maps into Cause 1: Node 24.22+ reads the source map file after it is removed
Harness: the published
Base on 24.22.1 prints The PR calls Cause 2: loader bundle URL is the same as the full bundle URL
The new unit test fails on base Other uses of the filename: Why both changes are usefulEach change alone makes the e2e test pass on Node 24.22.1. They fix different layers:
Repository checks run on PR head 4fe6389
Load-time cost of the eager findSourceMap callThe harness ran
Raw output of one series: On Node 24.21.0 there is no measurable difference. On Node 24.22.1 the PR adds about 35 ms for each compile of this map. This is the cost that Node 24.21.0 already has. This is a single-machine measurement with noise. Not covered
|
Co-authored-by: Phil Pluckthun <phil@kitten.sh>
….22+ (#52102) # Why Server stack traces in dev point at the wrong source on Node 24.22+ (`start-server-stack-traces.test.ts` fails on `jest-ubuntu (1)` whenever the runner gets 24.22.x): 1. Node 24.22 reads source maps lazily, after `@expo/require-utils` has deleted the temp map file. 2. Loader bundle URLs don't carry `isLoaderBundle`, so Metro's `/symbolicate` fallback rebuilds the full bundle and maps frames against it. # How - `load.ts`: call `findSourceMap()` before deleting the map file. - `metroOptions.ts`: add `transform.isLoaderBundle=true` to loader bundle URLs. # Test Plan - `start-server-stack-traces.test.ts` on Node 24.22.1: 4/4 fail before, 4/4 pass after. - New `metroOptions` unit test for the loader bundle URL. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Phil Pluckthun <phil@kitten.sh>
….22+ (#52102) Server stack traces in dev point at the wrong source on Node 24.22+ (`start-server-stack-traces.test.ts` fails on `jest-ubuntu (1)` whenever the runner gets 24.22.x): 1. Node 24.22 reads source maps lazily, after `@expo/require-utils` has deleted the temp map file. 2. Loader bundle URLs don't carry `isLoaderBundle`, so Metro's `/symbolicate` fallback rebuilds the full bundle and maps frames against it. - `load.ts`: call `findSourceMap()` before deleting the map file. - `metroOptions.ts`: add `transform.isLoaderBundle=true` to loader bundle URLs. - `start-server-stack-traces.test.ts` on Node 24.22.1: 4/4 fail before, 4/4 pass after. - New `metroOptions` unit test for the loader bundle URL. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Phil Pluckthun <phil@kitten.sh>
….22+ (#52102) Server stack traces in dev point at the wrong source on Node 24.22+ (`start-server-stack-traces.test.ts` fails on `jest-ubuntu (1)` whenever the runner gets 24.22.x): 1. Node 24.22 reads source maps lazily, after `@expo/require-utils` has deleted the temp map file. 2. Loader bundle URLs don't carry `isLoaderBundle`, so Metro's `/symbolicate` fallback rebuilds the full bundle and maps frames against it. - `load.ts`: call `findSourceMap()` before deleting the map file. - `metroOptions.ts`: add `transform.isLoaderBundle=true` to loader bundle URLs. - `start-server-stack-traces.test.ts` on Node 24.22.1: 4/4 fail before, 4/4 pass after. - New `metroOptions` unit test for the loader bundle URL. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Phil Pluckthun <phil@kitten.sh>
Why
Server stack traces in dev point at the wrong source on Node 24.22+ (
start-server-stack-traces.test.tsfails onjest-ubuntu (1)whenever the runner gets 24.22.x):@expo/require-utilshas deleted the temp map file.isLoaderBundle, so Metro's/symbolicatefallback rebuilds the full bundle and maps frames against it.How
load.ts: callfindSourceMap()before deleting the map file.metroOptions.ts: addtransform.isLoaderBundle=trueto loader bundle URLs.Test Plan
start-server-stack-traces.test.tson Node 24.22.1: 4/4 fail before, 4/4 pass after.metroOptionsunit test for the loader bundle URL.🤖 Generated with Claude Code