Exemplo
commander 15.0.0: Prevent process signal event listener leaks when repeatedly parsing git-style executable subcommands.
Amostra verificada para npm commander 15.0.0: Prevent process signal event listener leaks when repeatedly parsing git-style executable subcommands. O…
sha256:207479cba66934d262d039ee21e1dbd2749ff49fcdb3294797dec2f9b236d08f
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 3
- Chaves de assinatura que o compilaram
- 3
Ambiente declarado
node linux x64 node node npm
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-16 |
| node 22 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-18 |
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-09-08 |
Caso
HOW- Objetivo
- Prevent process signal event listener leaks when repeatedly parsing git-style executable subcommands.
- Pacotes
- Símbolos
-
- Command.prototype.parse
- Command.prototype.exitOverride
- Ambiente
- node
- Criado
- 2026-08-16T17:58:21Z
Contrato
- Spawning executable subcommands in commander registers signal event listeners on the global process object that are never unregistered upon process termination, accumulating memory leaks on subsequent command invocations.
Arquivos
- NOTES.md
- csx.json
- package-lock.json
- package.json
- test/contract.mjs
- test/mycli-sub.mjs
Código-fonte
# Notes
### What `search_known_solution` answered
The `search_known_solution` call returned no exact matches for commander, only unrelated samples covering CSV resource handling and OpenTelemetry SDK behaviors.
### What a model would have written instead
A typical model or developer expects that invoking a subcommand with Commander's executable runner cleans up all process-level event listeners once the spawned child process exits, leaving the global `process` object in its original state.
### How the wrong version fails
It silently leaks event listeners on the global `process` object for `SIGINT`, `SIGTERM`, `SIGUSR1`, `SIGUSR2`, and `SIGHUP` signals during each subcommand execution, retaining references to `ChildProcess` instances in memory, preventing garbage collection, and eventually triggering a `MaxListenersExceededWarning`.
{"case":{"believed":"Spawning git-style executable subcommands with Commander cleans up all process-level event listeners once the subcommand process exits.","caseId":"case:sha256:647aee2c1db84f82f2ec91ac1f86c0fbba93519da5601a566b1c8eb5f3cf800f","contract":["Spawning executable subcommands in commander registers signal event listeners on the global process object that are never unregistered upon process termination, accumulating memory leaks on subsequent command invocations."],"goal":"Prevent process signal event listener leaks when repeatedly parsing git-style executable subcommands.","kind":"HOW","packages":["pkg:npm/commander@15.0.0"],"schemaVersion":1,"symbols":["Command.prototype.parse","Command.prototype.exitOverride"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","ecosystem":"npm","executionContext":"node","language":"node","os":"linux","packageManager":"npm","runtime":"node","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/commander@15.0.0"],"schemaVersion":1,"symbols":["Command.prototype.parse","Command.prototype.exitOverride"],"verifierAdapter":"node-typescript@1"}
{
"name": "npm-commander-sample",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "npm-commander-sample",
"version": "1.0.0",
"dependencies": {
"commander": "^15.0.0"
}
},
"node_modules/commander": {
"version": "15.0.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-15.0.0.tgz",
"integrity": "sha512-z67u4ZhzCL/Tydu1lJARtEZYWbWaN7oYLHbsuzocr6y4N6WZAagG3RQ4FW61V1/0+jImpj293XfrcYnd1qxtPg==",
"license": "MIT",
"engines": {
"node": ">=22.12.0"
}
}
}
}
{
"name": "npm-commander-sample",
"version": "1.0.0",
"type": "module",
"dependencies": {
"commander": "^15.0.0"
}
}
import { Command } from 'commander';
import assert from 'assert';
async function run() {
const program = new Command();
program
.name('mycli')
.command('sub', 'run subcommand');
const beforeCount = process.listenerCount('SIGINT');
// First run
await new Promise((resolve) => {
program.exitOverride((err) => {
resolve();
});
program.parse(['node', './test/contract.mjs', 'sub']);
});
const countAfter1 = process.listenerCount('SIGINT');
assert.strictEqual(countAfter1, beforeCount + 1, 'Expected exactly 1 new SIGINT listener after the first run');
// Second run
await new Promise((resolve) => {
program.exitOverride((err) => {
resolve();
});
program.parse(['node', './test/contract.mjs', 'sub']);
});
const countAfter2 = process.listenerCount('SIGINT');
assert.strictEqual(countAfter2, beforeCount + 2, 'Expected exactly 2 new SIGINT listeners after the second run');
console.log('Contract verified: process signal event listeners leaked and accumulated.');
}
run().catch((err) => {
console.error(err);
process.exit(1);
});
process.exit(0);