Skip to content
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

fix: hide relaySignal from process.listeners() #194

Merged
merged 1 commit into from Mar 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/preflight.cts
Expand Up @@ -16,7 +16,7 @@
// If a parent process is detected
if (process.send) {
function relaySignal(signal: NodeJS.Signals) {
process.send!({

Check warning on line 19 in src/preflight.cts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Forbidden non-null assertion
type: 'kill',
signal,
});
Expand All @@ -38,11 +38,21 @@

// Reduce the listenerCount to hide the one set above
const { listenerCount } = process;
process.listenerCount = function (eventName) {

Check warning on line 41 in src/preflight.cts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Unexpected unnamed function
let count = Reflect.apply(listenerCount, this, arguments);
if (relaySignals.includes(eventName as any)) {

Check warning on line 43 in src/preflight.cts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Unexpected any. Specify a different type
count -= 1;
}
return count;
};

// Also hide relaySignal from process.listeners()
const { listeners } = process;
process.listeners = function (eventName) {

Check warning on line 51 in src/preflight.cts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Unexpected unnamed function
const result = Reflect.apply(listeners, this, arguments);
if (relaySignals.includes(eventName as any)) {

Check warning on line 53 in src/preflight.cts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Unexpected any. Specify a different type
return result.filter((listener: any) => listener !== relaySignal);
}
return result;
};
}