@@ -534,28 +534,31 @@ describe('Error recovery app', () => {
534
534
outdent `
535
535
import * as React from 'react';
536
536
let i = 0
537
- setInterval(() => {
538
- i++
539
- throw Error('no ' + i)
540
- }, 1000)
537
+ window.triggerError = () => {
538
+ // TODO(veil): sync thrown errors do not trigger Redbox.
539
+ setTimeout(() => {
540
+ i++
541
+ throw Error('no ' + i)
542
+ }, 0)
543
+ }
541
544
export default function FunctionNamed() {
542
545
return <div />
543
546
}
544
547
`
545
548
)
546
549
547
- await new Promise ( ( resolve ) => setTimeout ( resolve , 1000 ) )
550
+ await browser . eval ( 'window.triggerError()' )
548
551
await expect ( browser ) . toDisplayCollapsedRedbox ( `
549
552
{
550
553
"count": 1,
551
554
"description": "Error: no 1",
552
555
"environmentLabel": null,
553
556
"label": "Unhandled Runtime Error",
554
- "source": "index.js (5:9 ) @ eval
555
- > 5 | throw Error('no ' + i)
556
- | ^",
557
+ "source": "index.js (7:11 ) @ eval
558
+ > 7 | throw Error('no ' + i)
559
+ | ^",
557
560
"stack": [
558
- "eval index.js (5:9 )",
561
+ "eval index.js (7:11 )",
559
562
],
560
563
}
561
564
` )
@@ -566,10 +569,13 @@ describe('Error recovery app', () => {
566
569
outdent `
567
570
import * as React from 'react';
568
571
let i = 0
569
- setInterval(() => {
570
- i++
571
- throw Error('no ' + i)
572
- }, 1000)
572
+ window.triggerError = () => {
573
+ // TODO(veil): sync thrown errors do not trigger Redbox.
574
+ setTimeout(() => {
575
+ i++
576
+ throw Error('no ' + i)
577
+ }, 0)
578
+ }
573
579
export default function FunctionNamed() {
574
580
`
575
581
)
@@ -598,13 +604,10 @@ describe('Error recovery app', () => {
598
604
"label": "Build Error",
599
605
"source": "./index.js
600
606
Error: x Expected '}', got '<eof>'
601
- ,-[7:1]
602
- 4 | i++
603
- 5 | throw Error('no ' + i)
604
- 6 | }, 1000)
605
- 7 | export default function FunctionNamed() {
606
- : ^
607
- \`----
607
+ ,-[10:1]
608
+ 10 | export default function FunctionNamed() {
609
+ : ^
610
+ \`----
608
611
Caused by:
609
612
Syntax Error
610
613
Import trace for requested module:
@@ -616,7 +619,7 @@ describe('Error recovery app', () => {
616
619
}
617
620
618
621
// Test that runtime error does not take over:
619
- await new Promise ( ( resolve ) => setTimeout ( resolve , 2000 ) )
622
+ await browser . eval ( 'window.triggerError()' )
620
623
if ( isTurbopack ) {
621
624
await expect ( browser ) . toDisplayRedbox ( `
622
625
{
@@ -640,13 +643,10 @@ describe('Error recovery app', () => {
640
643
"label": "Build Error",
641
644
"source": "./index.js
642
645
Error: x Expected '}', got '<eof>'
643
- ,-[7:1]
644
- 4 | i++
645
- 5 | throw Error('no ' + i)
646
- 6 | }, 1000)
647
- 7 | export default function FunctionNamed() {
648
- : ^
649
- \`----
646
+ ,-[10:1]
647
+ 10 | export default function FunctionNamed() {
648
+ : ^
649
+ \`----
650
650
Caused by:
651
651
Syntax Error
652
652
Import trace for requested module:
0 commit comments