-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Lambdas can be called multiple times in the same container. Calling registerCrashHandler multiple times is the same process throws an error with the message: Crash Handler cannot be used alongside other uncaughtException or unhandledRejection handlers.
What problem does this feature solve?
- It is frustrating to see these errors in production but not during development because Serverless Offline does not reuse containers by default
- It should not be necessary to do this in code:
const existingListeners = [
...process.listeners('uncaughtException'),
...process.listeners('unhandledRejection')
];
if (!existingListeners.length {
registerCrashHandler();
}Ideal solution
I am not sure, but maybe one of:
- Defaulting to allowing multiple registrations? Maybe when running in a Lambda only?
- Allowing users to specify that they know it is safe to register multiple times via an option. This won't solve the first issue, though.
Alternatives
Update docs to make it clear that we need to do something different in AWS Lambdas.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request