Skip to content

Commit

Permalink
Give each fake eval its own URL
Browse files Browse the repository at this point in the history
This is needed when looking up a source location from an error string
where the engine doesn't have access to the native reference.

Async stacks are printed with native references but errors printed into the
console are printed as strings and then reverse engineered back into source
mapped urls. This preserves each eval as its own id.
  • Loading branch information
sebmarkbage committed Jun 5, 2024
1 parent 37ef415 commit 1fa0a71
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/react-client/src/ReactFlightClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -1701,6 +1701,7 @@ const fakeFunctionCache: Map<string, FakeFunction<any>> = __DEV__
? new Map()
: (null: any);

let idx = 0;
function createFakeFunction<T>(
name: string,
filename: string,
Expand Down Expand Up @@ -1730,7 +1731,7 @@ function createFakeFunction<T>(
}

if (filename) {
code += '\n//# sourceURL=' + filename;
code += '\n//# sourceURL=' + filename + '?' + (idx++);
}
if (sourceMap) {
code += '\n//# sourceMappingURL=' + sourceMap;
Expand Down

0 comments on commit 1fa0a71

Please sign in to comment.