-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: dedupe consecutive captured console errors
- Loading branch information
Showing
5 changed files
with
80 additions
and
14 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
...ges/next/src/client/components/react-dev-overlay/internal/helpers/enqueue-client-error.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { isHydrationError } from '../../../is-hydration-error' | ||
|
||
// Dedupe the two consecutive errors: If the previous one is same as current one, ignore the current one. | ||
export function enqueueConsecutiveDedupedError( | ||
queue: Array<Error>, | ||
error: Error | ||
) { | ||
const isFront = isHydrationError(error) | ||
const previousError = isFront ? queue[0] : queue[queue.length - 1] | ||
// Only check message to see if it's the same error, as message is representative display in the console. | ||
if (previousError && previousError.message === error.message) { | ||
return | ||
} | ||
// TODO: change all to push error into errorQueue, | ||
// currently there's a async api error is always erroring while hydration error showing up. | ||
// Move hydration error to the front of the queue to unblock. | ||
if (isFront) { | ||
queue.unshift(error) | ||
} else { | ||
queue.push(error) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
6 changes: 6 additions & 0 deletions
6
test/development/app-dir/capture-console-error/app/browser/render/page.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use client' | ||
|
||
export default function Page() { | ||
console.error('trigger an console.error in render') | ||
return <p>render</p> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters