Skip to content

Commit

Permalink
Use brackets instead of parenthesis in empty name eval (#30449)
Browse files Browse the repository at this point in the history
Otherwise V8 will parse it as a URL and mess it up. The bracket is a
magic string meaning empty.
  • Loading branch information
sebmarkbage authored Jul 24, 2024
1 parent a6b7e43 commit 933b737
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/react-client/src/ReactFlightClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -1955,7 +1955,7 @@ function createFakeFunction<T>(

if (!name) {
// An eval:ed function with no name gets the name "eval". We give it something more descriptive.
name = '(anonymous)';
name = '<anonymous>';
}
const encodedName = JSON.stringify(name);
// We generate code where the call is at the line and column of the server executed code.
Expand Down
4 changes: 2 additions & 2 deletions packages/react-client/src/__tests__/ReactFlight-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1285,8 +1285,8 @@ describe('ReactFlight', () => {
'Error: This is an error\n' +
' at eval (eval at testFunction (eval at createFakeFunction (**), <anonymous>:1:35)\n' +
' at ServerComponentError (file://~/(some)(really)(exotic-directory)/ReactFlight-test.js:1166:19)\n' +
' at (anonymous) (file:///testing.js:42:3)\n' +
' at (anonymous) (file:///testing.js:42:3)\n',
' at <anonymous> (file:///testing.js:42:3)\n' +
' at <anonymous> (file:///testing.js:42:3)\n',
)
: expect.stringContaining(
'Error: This is an error\n' +
Expand Down

0 comments on commit 933b737

Please sign in to comment.