| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 63091f8 commit 7134d49
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -378,14 +378,13 @@ function execFile(file /* , args, options, callback */) { | |||
| 378 | 378 | if (options.signal.aborted) { | |
| 379 | 379 | process.nextTick(() => kill()); | |
| 380 | 380 | } else { | |
| 381 | + const childController = new AbortController(); | ||
| 381 | 382 | options.signal.addEventListener('abort', () => { | |
| 382 | - if (!ex) { | ||
| 383 | + if (!ex) | ||
| 383 | 384 | ex = new AbortError(); | |
| 384 | - } | ||
| 385 | 385 | kill(); | |
| 386 | - }); | ||
| 387 | - const remove = () => options.signal.removeEventListener('abort', kill); | ||
| 388 | - child.once('close', remove); | ||
| 386 | + }, { signal: childController.signal }); | ||
| 387 | + child.once('close', () => childController.abort()); | ||
| 389 | 388 | } | |
| 390 | 389 | } | |
| 391 | 390 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,6 +3,7 @@ | |||
| 3 | 3 | const common = require('../common'); | |
| 4 | 4 | const assert = require('assert'); | |
| 5 | 5 | const execFile = require('child_process').execFile; | |
| 6 | + const { getEventListeners } = require('events'); | ||
| 6 | 7 | const { getSystemErrorName } = require('util'); | |
| 7 | 8 | const fixtures = require('../common/fixtures'); | |
| 8 | 9 | ||
@@ -68,5 +69,15 @@ const execOpts = { encoding: 'utf8', shell: true }; | |||
| 68 | 69 | ||
| 69 | 70 | execFile(process.execPath, [echoFixture, 0], { signal: 'hello' }, callback); | |
| 70 | 71 | }, { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' }); | |
| 72 | + } | ||
| 73 | + { | ||
| 74 | + // Verify that the process completing removes the abort listener | ||
| 75 | + const ac = new AbortController(); | ||
| 76 | + const { signal } = ac; | ||
| 71 | 77 | ||
| 78 | + const callback = common.mustCall((err) => { | ||
| 79 | + assert.strictEqual(getEventListeners(ac.signal).length, 0); | ||
| 80 | + assert.strictEqual(err, null); | ||
| 81 | + }); | ||
| 82 | + execFile(process.execPath, [fixture, 0], { signal }, callback); | ||
| 72 | 83 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments