mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
### Why? The Instant DevTools closes when opening the error overlay and continues hydration. This is annoying when I wanted to check the error, but didn't mean to stop the capture. Before: [github.com/user-attachments/assets/f1de72a9-5a2b-4e4e-bd7e-e7f36c975ea7](https://github.com/user-attachments/assets/f1de72a9-5a2b-4e4e-bd7e-e7f36c975ea7) After: https://github.com/user-attachments/assets/f060e11e-9d60-43f6-a1fd-ca735fad1aa1
23 lines
666 B
TypeScript
23 lines
666 B
TypeScript
'use client'
|
|
|
|
export function ErrorTrigger() {
|
|
return (
|
|
<button
|
|
type="button"
|
|
data-testid="trigger-error"
|
|
onClick={() => {
|
|
// Throw asynchronously so the error is reported to the dev overlay's
|
|
// issue list (the badge toast) WITHOUT auto-opening the overlay. A
|
|
// render-time throw would be caught by AppDevOverlayErrorBoundary, which
|
|
// calls openErrorOverlay() and auto-opens the overlay, preempting the
|
|
// toast-click path these tests exercise.
|
|
setTimeout(() => {
|
|
throw new Error('Instant nav devtools test error')
|
|
})
|
|
}}
|
|
>
|
|
Trigger error
|
|
</button>
|
|
)
|
|
}
|