Skip to content

Commit

Permalink
fix(CLI): Fix SIGINT signal handling
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Jul 7, 2021
1 parent b86f8cd commit c5a3f69
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions scripts/serverless.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ process.once('uncaughtException', (error) => {
});
});

process.on('SIGINT', () => {
process.once('SIGINT', () => {
clearTimeout(keepAliveTimer);
// If there's another SIGINT listener (command that works as deamon or reads stdin input)
// then let the other listener decide how process will exit
const isOtherSigintListener = Boolean(process.listenerCount('SIGINT'));
if (
commandSchema &&
!hasTelemetryBeenReported &&
Expand All @@ -74,7 +77,7 @@ process.on('SIGINT', () => {
});
storeTelemetryLocally({ ...telemetryPayload, outcome: 'interrupt' });
}
process.exit(1);
if (!isOtherSigintListener) process.exit(130);
});

const processSpanPromise = (async () => {
Expand Down

0 comments on commit c5a3f69

Please sign in to comment.