elastic / elastic/apm-agent-nodejs

an uncaught exception in captureError can result in infinite loop: can we guard that generally?

Open
#2,150 0 comments 0 reactions 0 assignees View on GitHub
agent-nodejs
Dominant language
JavaScript
Stars
594
Forks
244
Avg merge
1d 8h
Merged PRs (30d)
16

Description

An uncaught exception in `captureError` can lead to an infinite loop between captureError ->
uncaught exception -> captureError, if `apm.captureError()` is called in a `process.on('uncaughtException', ...)`
handler. The agent does this itself if `captureExceptions: true`, which is the default.
https://github.com/elastic/apm-agent-nodejs/issues/2148 is an example of where this can happen.

This ticket is to think about if there is a general guard we could put on this. For example, could we use Async Local Storage to track if we are currently handling an uncaught exception, and if so, then abort starting another uncaught exception handler.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.