Skip to content

fix(error-handling): prevent infinite recursion when errorHandler throws#13370

Open
ifer47 wants to merge 2 commits into
vuejs:mainfrom
ifer47:fix/prevent-recursive-error-handling
Open

fix(error-handling): prevent infinite recursion when errorHandler throws#13370
ifer47 wants to merge 2 commits into
vuejs:mainfrom
ifer47:fix/prevent-recursive-error-handling

Conversation

@ifer47

@ifer47 ifer47 commented Jun 16, 2026

Copy link
Copy Markdown

Summary

  • Add isHandlingError guard to prevent infinite recursion when the custom error handler itself throws an error
  • Previously, if config.errorHandler threw, it would trigger handleError again, which calls the error handler again, causing infinite recursion and Maximum call stack size exceeded
  • The guard ensures that if handleError is called while already handling an error, it returns early instead of re-entering the error handling flow

Problem

When a custom config.errorHandler throws an error, the following chain occurs:

  1. invokeWithErrorHandling catches the original error
  2. Calls handleError
  3. handleError calls globalHandleError
  4. globalHandleError calls config.errorHandler
  5. If errorHandler throws, it calls logError
  6. If logError or any code path leads back to invokeWithErrorHandling, the cycle repeats
  7. Result: RangeError: Maximum call stack size exceeded

Changes

  • Added module-level isHandlingError flag
  • Set flag to true at the start of handleError
  • Early return with popTarget() if already handling an error
  • Reset flag to false in the finally block
  • Added test case to verify the fix

Closes #13241

🤖 Generated with Claude Code Best

Contributor and others added 2 commits June 16, 2026 23:31
When a custom errorHandler throws an error, it triggers handleError
again which calls the errorHandler again, causing infinite recursion
and a "Maximum call stack size exceeded" error.

Add an isHandlingError guard to prevent re-entering handleError while
it's already processing an error. This ensures that errors thrown by
the errorHandler itself are logged without causing recursive calls.

Closes vuejs#13241

Co-Authored-By: zhipu/glm-5 <zai-org@claude-code-best.win>
Co-Authored-By: zhipu/glm-5 <zai-org@claude-code-best.win>
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.

Custom error handler causing recursive error handling leading to Maximum call stack size exceeded error

1 participant