Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react-client/src/ReactFlightReplyClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ function createFakeServerFunction<A: Iterable<any>, T>(
'\n//# sourceURL=rsc://React/' +
encodeURIComponent(environmentName) +
'/' +
filename +
encodeURI(filename) +
'?s' + // We add an extra s here to distinguish from the fake stack frames
fakeServerFunctionIdx++;
code += '\n//# sourceMappingURL=' + sourceMap;
Expand Down
8 changes: 7 additions & 1 deletion packages/react-client/src/__tests__/ReactFlight-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,9 @@ describe('ReactFlight', () => {
' at file:///testing.js:42:3',
// async anon function (https://github.com/ChromeDevTools/devtools-frontend/blob/831be28facb4e85de5ee8c1acc4d98dfeda7a73b/test/unittests/front_end/panels/console/ErrorStackParser_test.ts#L130C9-L130C41)
' at async file:///testing.js:42:3',
// third-party RSC frame
// Ideally this would be a real frame produced by React not a mocked one.
' at ThirdParty (rsc://React/ThirdParty/file:///code/%5Broot%2520of%2520the%2520server%5D.js?42:1:1)',
// host component in parent stack
' at div (<anonymous>)',
...originalStackLines.slice(2),
Expand Down Expand Up @@ -1360,7 +1363,10 @@ describe('ReactFlight', () => {
return functionName === 'div';
}
return (
!filename.startsWith('node:') && !filename.includes('node_modules')
!filename.startsWith('node:') &&
!filename.includes('node_modules') &&
// sourceURL from an ES module in `/code/[root of the server].js`
filename !== 'file:///code/[root%20of%20the%20server].js'
);
},
});
Expand Down
4 changes: 2 additions & 2 deletions packages/react-server/src/ReactFlightServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ function devirtualizeURL(url: string): string {
// We need to reverse it back into the original location by stripping its prefix
// and suffix. We don't need the environment name because it's available on the
// parent object that will contain the stack.
const envIdx = url.indexOf('/', 12);
const envIdx = url.indexOf('/', 'rsc://React/'.length);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this get optimized by closure?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const suffixIdx = url.lastIndexOf('?');
if (envIdx > -1 && suffixIdx > -1) {
return url.slice(envIdx + 1, suffixIdx);
return decodeURI(url.slice(envIdx + 1, suffixIdx));
}
}
return url;
Expand Down
Loading