-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log uncaughtException
s in our logging system
#183530
Conversation
|
||
expect(logger.get('process').warn).toHaveBeenCalledTimes(1); | ||
expect(logger.get('environment').warn).toHaveBeenCalledTimes(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird that the test works with both words 🤷
await service.preboot({ analytics }); | ||
|
||
const err = new Error('something went wrong'); | ||
process.emit('unhandledRejection', err, new Promise((res, rej) => rej(err))); | ||
process.emit('unhandledRejection', err, new Promise((res, rej) => {})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem was not the process.emit
, was the actual Promise rejecting 😅
@@ -68,6 +68,14 @@ export class EnvironmentService { | |||
const message = (reason as Error)?.stack ?? JSON.stringify(reason); | |||
this.log.warn(`Detected an unhandled Promise rejection: ${message}`); | |||
}); | |||
// Log uncaughtExceptions in our logger before crashing the process: https://github.com/elastic/kibana/issues/183182 | |||
process.on('uncaughtExceptionMonitor', (error, origin) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using uncaughtExceptionMonitor
instead of uncaughtException
because, according to the docs, the only difference is that the latter intercepts the exit call.
/ci |
Pinging @elastic/kibana-core (Team:Core) |
💚 Build Succeeded
Metrics [docs]
History
To update your PR or re-run it, just comment with: cc @afharo |
Summary
Resolves #183182
Checklist
Risk Matrix
unhandledRejection
s (refer to theorigin
parameter).For maintainers