Skip to content

fix: prevent ErrorBoundary onError from spamming null callbacks on every update#2318

Open
AshayK003 wants to merge 1 commit into
appbaseio:nextfrom
AshayK003:fix/error-boundary-callback-spam
Open

fix: prevent ErrorBoundary onError from spamming null callbacks on every update#2318
AshayK003 wants to merge 1 commit into
appbaseio:nextfrom
AshayK003:fix/error-boundary-callback-spam

Conversation

@AshayK003

Copy link
Copy Markdown

Problem

The componentDidUpdate method in ErrorBoundary unconditionally called invokeErrorCallback(), which fires this.props.onError(null, componentId) on every re-render — even when no error exists. This spams consumer error monitoring with null-error notifications on every component update.

Root Cause

componentDidUpdate() {
    if (this.props.error && !this.state.error) {
        this.setState({ error: this.props.error });
    }
    this.invokeErrorCallback();  // ← fires on every update, even without error
}

Fix

Guard invokeErrorCallback() behind this.state.error, so it only fires when an actual error exists in state:

if (this.state.error) {
    this.invokeErrorCallback();
}

Testing

Snapshot test already exists. The render output is unchanged — only the callback invocation path is gated. No visual regression.

…ery update

The componentDidUpdate method unconditionally called invokeErrorCallback(),
which fired this.props.onError(null, componentId) on every re-render
even when no error was present. This caused unnecessary null-error
notifications in consumer error monitoring.

Added a guard so invokeErrorCallback is only called when this.state.error
is truthy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant