@samitouri / QOS-React / commits / 933b737f64

Use brackets instead of parenthesis in empty name eval (#30449)

Otherwise V8 will parse it as a URL and mess it up. The bracket is a magic string meaning empty.

Sebastian Markbåge committed Jul 24, 2024 at 17:45 UTC 933b737f64808559272c822b80699f4db84773a4
2 files changed +3 -3
packages/react-client/src/ReactFlightClient.js
+1 -1
@@ -1955,7 +1955,7 @@ function createFakeFunction<T>(
1955
1956 if (!name) {
1957 // An eval:ed function with no name gets the name "eval". We give it something more descriptive.
1958 - name = '(anonymous)';
1958 + name = '<anonymous>';
1959 }
1960 const encodedName = JSON.stringify(name);
1961 // We generate code where the call is at the line and column of the server executed code.
packages/react-client/src/__tests__/ReactFlight-test.js
+2 -2
@@ -1285,8 +1285,8 @@ describe('ReactFlight', () => {
1285 'Error: This is an error\n' +
1286 ' at eval (eval at testFunction (eval at createFakeFunction (**), <anonymous>:1:35)\n' +
1287 ' at ServerComponentError (file://~/(some)(really)(exotic-directory)/ReactFlight-test.js:1166:19)\n' +
1288 - ' at (anonymous) (file:///testing.js:42:3)\n' +
1289 - ' at (anonymous) (file:///testing.js:42:3)\n',
1288 + ' at <anonymous> (file:///testing.js:42:3)\n' +
1289 + ' at <anonymous> (file:///testing.js:42:3)\n',
1290 )
1291 : expect.stringContaining(
1292 'Error: This is an error\n' +