Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
- Fixes issue where database emulator did not properly load initial rules (#2483).
- Allow starting the UI with `emulators:exec` using the `--ui` flag.
- Fixes issue where multiple CLI instances compete for the same log (#2464).
- Fixes issue where emulators run from `npm` scripts could not be shut down cleanly (#2507).
12 changes: 12 additions & 0 deletions src/emulator/commandUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,22 @@ function processKillSignal(
rej: (value?: unknown) => void,
options: any
): SignalsListener {
let lastSignal = new Date().getTime();
let signalCount = 0;
return async () => {
try {
const now = new Date().getTime();
const diff = now - lastSignal;
if (diff < 100) {
// If we got a signal twice in 100ms it likely was not an intentional human action.
// It could be a shaky MacBook keyboard or a known issue with "npm" scripts and signals.
logger.debug(`Ignoring signal ${signal} due to short delay of ${diff}ms`);
return;
}

signalCount = signalCount + 1;
lastSignal = now;

const signalDisplay = signal === "SIGINT" ? `SIGINT (Ctrl-C)` : signal;
logger.debug(`Received signal ${signalDisplay} ${signalCount}`);
logger.info(" "); // to not indent the log with the possible Ctrl-C char
Expand Down