@@ -36,15 +36,15 @@ describe('app-dir - server source maps', () => {
3636 } )
3737 expect ( normalizeCliOutput ( next . cliOutput . slice ( outputIndex ) ) ) . toContain (
3838 '\nError: rsc-error-log' +
39- '\n at logError (app/rsc-error-log/page.js:5 :16)' +
40- '\n at Page (app/rsc-error-log/page.js:12 :2)' +
41- '\n 3 |' +
42- '\n 4 | function logError() {' +
43- "\n> 5 | const error = new Error('rsc-error-log')" +
39+ '\n at logError (app/rsc-error-log/page.js:4 :16)' +
40+ '\n at Page (app/rsc-error-log/page.js:9 :2)' +
41+ '\n 2 |' +
42+ '\n 3 | function logError() {' +
43+ "\n> 4 | const error = new Error('rsc-error-log')" +
4444 '\n | ^' +
45- '\n 6 | console.error(error)' +
46- '\n 7 | }' +
47- '\n 8 |' +
45+ '\n 5 | console.error(error)' +
46+ '\n 6 | }' +
47+ '\n 7 |' +
4848 '\n'
4949 )
5050 } else {
@@ -64,24 +64,23 @@ describe('app-dir - server source maps', () => {
6464 } )
6565 expect ( normalizeCliOutput ( next . cliOutput . slice ( outputIndex ) ) ) . toContain (
6666 '\nError: rsc-error-log-cause' +
67- '\n at logError (app/rsc-error-log-cause/page.js:4:16)' +
68- '\n at Page (app/rsc-error-log-cause/page.js:12:2)' +
69- '\n 2 |' +
70- '\n 3 | function logError(cause) {' +
71- "\n> 4 | const error = new Error('rsc-error-log-cause', { cause })" +
67+ '\n at logError (app/rsc-error-log-cause/page.js:2:16)' +
68+ '\n at Page (app/rsc-error-log-cause/page.js:8:2)' +
69+ '\n 1 | function logError(cause) {' +
70+ "\n> 2 | const error = new Error('rsc-error-log-cause', { cause })" +
7271 '\n | ^' +
73- '\n 5 | console.error(error)' +
74- '\n 6 | }' +
75- '\n 7 | {' +
72+ '\n 3 | console.error(error)' +
73+ '\n 4 | }' +
74+ '\n 5 | {' +
7675 '\n [cause]: Error: Boom' +
77- '\n at Page (app/rsc-error-log-cause/page.js:11 :16)' +
78- '\n 9 | await connection() ' +
79- '\n 10 | ' +
80- "\n > 11 | const error = new Error('Boom')" +
76+ '\n at Page (app/rsc-error-log-cause/page.js:7 :16)' +
77+ '\n 5 | ' +
78+ '\n 6 | export default function Page() { ' +
79+ "\n > 7 | const error = new Error('Boom')" +
8180 '\n | ^' +
82- '\n 12 | logError(error)' +
83- '\n 13 | return null' +
84- '\n 14 | }' +
81+ '\n 8 | logError(error)' +
82+ '\n 9 | return null' +
83+ '\n 10 | }' +
8584 '\n'
8685 )
8786 } else {
@@ -207,39 +206,39 @@ describe('app-dir - server source maps', () => {
207206 expect ( normalizeCliOutput ( next . cliOutput . slice ( outputIndex ) ) ) . toContain (
208207 isTurbopack
209208 ? '\nError: rsc-error-log-ignore-listed' +
210- '\n at logError (app/rsc-error-log-ignore-listed/page.js:9 :16)' +
211- '\n at runWithInternalIgnored (app/rsc-error-log-ignore-listed/page.js:21 :12)' +
212- '\n at runWithExternalSourceMapped (app/rsc-error-log-ignore-listed/page.js:20 :29)' +
213- '\n at runWithExternal (app/rsc-error-log-ignore-listed/page.js:19 :32)' +
214- '\n at runWithInternalSourceMapped (app/rsc-error-log-ignore-listed/page.js:18 :18)' +
209+ '\n at logError (app/rsc-error-log-ignore-listed/page.js:8 :16)' +
210+ '\n at runWithInternalIgnored (app/rsc-error-log-ignore-listed/page.js:18 :12)' +
211+ '\n at runWithExternalSourceMapped (app/rsc-error-log-ignore-listed/page.js:17 :29)' +
212+ '\n at runWithExternal (app/rsc-error-log-ignore-listed/page.js:16 :32)' +
213+ '\n at runWithInternalSourceMapped (app/rsc-error-log-ignore-listed/page.js:15 :18)' +
215214 // Realpath does not point into node_modules so we don't ignore it.
216215 // TODO(veil): Should be internal-pkg/sourcemapped.ts
217216 '\n at runInternalSourceMapped (sourcemapped.ts:5:9)' +
218- '\n at runWithInternal (app/rsc-error-log-ignore-listed/page.js:17 :28)' +
217+ '\n at runWithInternal (app/rsc-error-log-ignore-listed/page.js:14 :28)' +
219218 // Realpath does not point into node_modules so we don't ignore it.
220219 '\n at runInternal (internal-pkg/index.js:2:9)' +
221- '\n at Page (app/rsc-error-log-ignore-listed/page.js:16 :14)' +
222- '\n 7 |' +
220+ '\n at Page (app/rsc-error-log-ignore-listed/page.js:13 :14)' +
221+ '\n 6 |' +
223222 '\n'
224223 : '\nError: rsc-error-log-ignore-listed' +
225- '\n at logError (app/rsc-error-log-ignore-listed/page.js:9 :16)' +
226- '\n at runWithInternalIgnored (app/rsc-error-log-ignore-listed/page.js:21 :12)' +
224+ '\n at logError (app/rsc-error-log-ignore-listed/page.js:8 :16)' +
225+ '\n at runWithInternalIgnored (app/rsc-error-log-ignore-listed/page.js:18 :12)' +
227226 // TODO(veil): Webpacks's sourcemap loader drops `ignoreList`
228227 // TODO(veil): Webpack's sourcemap loader creates an incorrect `sources` entry.
229228 // Can be worked around by using `./sourcemapped.ts` instead of `sourcemapped.ts`.
230229 '\n at runInternalIgnored (webpack-internal:/(rsc)/internal-pkg/ignored.ts:6:9)' +
231- '\n at runWithExternalSourceMapped (app/rsc-error-log-ignore-listed/page.js:20 :29)' +
232- '\n at runWithExternal (app/rsc-error-log-ignore-listed/page.js:19 :32)' +
233- '\n at runWithInternalSourceMapped (app/rsc-error-log-ignore-listed/page.js:18 :18)' +
230+ '\n at runWithExternalSourceMapped (app/rsc-error-log-ignore-listed/page.js:17 :29)' +
231+ '\n at runWithExternal (app/rsc-error-log-ignore-listed/page.js:16 :32)' +
232+ '\n at runWithInternalSourceMapped (app/rsc-error-log-ignore-listed/page.js:15 :18)' +
234233 // TODO(veil): Webpack's sourcemap loader creates an incorrect `sources` entry.
235234 // Can be worked around by using `./sourcemapped.ts` instead of `sourcemapped.ts`.
236235 // Realpath does not point into node_modules so we don't ignore it.
237236 '\n at runInternalSourceMapped (webpack-internal:/(rsc)/internal-pkg/sourcemapped.ts:5:9)' +
238- '\n at runWithInternal (app/rsc-error-log-ignore-listed/page.js:17 :28)' +
237+ '\n at runWithInternal (app/rsc-error-log-ignore-listed/page.js:14 :28)' +
239238 // Realpath does not point into node_modules so we don't ignore it.
240239 '\n at runInternal (internal-pkg/index.js:2:9)' +
241- '\n at Page (app/rsc-error-log-ignore-listed/page.js:16 :14)' +
242- '\n 7 |' +
240+ '\n at Page (app/rsc-error-log-ignore-listed/page.js:13 :14)' +
241+ '\n 6 |' +
243242 '\n'
244243 )
245244 } else {
@@ -293,42 +292,47 @@ describe('app-dir - server source maps', () => {
293292 } )
294293
295294 it ( 'logged errors preserve their name' , async ( ) => {
296- const outputIndex = next . cliOutput . length
297- await next . render ( '/rsc-error-log-custom-name' )
295+ let cliOutput = next . cliOutput
296+ if ( isNextDev ) {
297+ const outputIndex = next . cliOutput . length
298+ await next . render ( '/rsc-error-log-custom-name' )
299+ cliOutput = next . cliOutput . slice ( outputIndex )
300+ }
298301
299302 await retry ( ( ) => {
300- expect ( next . cliOutput . slice ( outputIndex ) ) . toContain (
303+ expect ( cliOutput ) . toContain (
301304 // TODO: isNextDev ? 'UnnamedError: rsc-error-log-custom-name-Foo' : '[Error]: rsc-error-log-custom-name-Foo'
302305 isNextDev
303306 ? 'Error: rsc-error-log-custom-name-Foo'
304307 : 'Error: rsc-error-log-custom-name-Foo'
305308 )
306309 } )
307310
308- expect ( next . cliOutput . slice ( outputIndex ) ) . toContain (
311+ expect ( cliOutput ) . toContain (
309312 // TODO: isNextDev ? 'NamedError [MyError]: rsc-error-log-custom-name-Bar' : '[MyError]: rsc-error-log-custom-name-Bar'
310- isNextDev ? 'Error [MyError]: rsc-error-log-custom-name-Bar' : 'Error [MyError]: rsc-error-log-custom-name-Bar'
313+ isNextDev
314+ ? 'Error [MyError]: rsc-error-log-custom-name-Bar'
315+ : 'Error [MyError]: rsc-error-log-custom-name-Bar'
311316 )
312317 } )
313318
314319 it ( 'handles invalid sourcemaps gracefully' , async ( ) => {
315- const outputIndex = next . cliOutput . length
316- await next . render ( '/bad-sourcemap' )
317-
318- await retry ( ( ) => {
319- expect ( normalizeCliOutput ( next . cliOutput . slice ( outputIndex ) ) ) . toContain (
320- 'Error: bad-sourcemap'
321- )
322- } )
323-
324320 if ( isNextDev ) {
321+ const outputIndex = next . cliOutput . length
322+ await next . render ( '/bad-sourcemap' )
323+
324+ await retry ( ( ) => {
325+ expect ( normalizeCliOutput ( next . cliOutput . slice ( outputIndex ) ) ) . toContain (
326+ 'Error: bad-sourcemap'
327+ )
328+ } )
325329 if ( isTurbopack ) {
326330 expect ( normalizeCliOutput ( next . cliOutput . slice ( outputIndex ) ) ) . toContain (
327331 // Node.js is fine with invalid URLs in index maps apparently.
328332 '' +
329333 '\nError: bad-sourcemap' +
330- '\n at logError (custom://[badhost]/app/bad-sourcemap/page.js:8 :16)' +
331- '\n at Page (custom://[badhost]/app/bad-sourcemap/page.js:13 :2)' +
334+ '\n at logError (custom://[badhost]/app/bad-sourcemap/page.js:6 :16)' +
335+ '\n at Page (custom://[badhost]/app/bad-sourcemap/page.js:10 :2)' +
332336 // TODO: Remove blank line
333337 '\n'
334338 )
@@ -340,15 +344,16 @@ describe('app-dir - server source maps', () => {
340344 '' +
341345 `\nwebpack-internal:///(rsc)/./app/bad-sourcemap/page.js: Invalid source map. Only conformant source maps can be used to find the original code. Cause: TypeError [ERR_INVALID_ARG_TYPE]: The "payload" argument must be of type object. Received null` +
342346 '\nError: bad-sourcemap' +
343- '\n at logError (webpack-internal:///(rsc)/./app/bad-sourcemap/page.js:14 :19)' +
344- '\n at Page (webpack-internal:///(rsc)/./app/bad-sourcemap/page.js:18 :5)'
347+ '\n at logError (webpack-internal:///(rsc)/./app/bad-sourcemap/page.js:12 :19)' +
348+ '\n at Page (webpack-internal:///(rsc)/./app/bad-sourcemap/page.js:15 :5)'
345349 )
346- // Expect the invalid sourcemap warning only once.
350+ // Expect the invalid sourcemap warning only once per render.
351+ // Dynamic I/O renders three times.
347352 expect (
348353 normalizeCliOutput ( next . cliOutput . slice ( outputIndex ) ) . split (
349354 'Invalid source map.'
350355 ) . length - 1
351- ) . toEqual ( 1 )
356+ ) . toEqual ( 3 )
352357 }
353358 } else {
354359 // TODO: test `next start` with `--enable-source-maps`
0 commit comments