| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent dc63ca6 commit 6c08c9d
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -365,14 +365,13 @@ function execFile(file /* , args, options, callback */) { | |||
| 365 | 365 | if (options.signal.aborted) { | |
| 366 | 366 | process.nextTick(() => kill()); | |
| 367 | 367 | } else { | |
| 368 | + const childController = new AbortController(); | ||
| 368 | 369 | options.signal.addEventListener('abort', () => { | |
| 369 | - if (!ex) { | ||
| 370 | + if (!ex) | ||
| 370 | 371 | ex = new AbortError(); | |
| 371 | - } | ||
| 372 | 372 | kill(); | |
| 373 | - }); | ||
| 374 | - const remove = () => options.signal.removeEventListener('abort', kill); | ||
| 375 | - child.once('close', remove); | ||
| 373 | + }, { signal: childController.signal }); | ||
| 374 | + child.once('close', () => childController.abort()); | ||
| 376 | 375 | } | |
| 377 | 376 | } | |
| 378 | 377 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,6 +4,7 @@ | |||
| 4 | 4 | const common = require('../common'); | |
| 5 | 5 | const assert = require('assert'); | |
| 6 | 6 | const execFile = require('child_process').execFile; | |
| 7 | + const { getEventListeners } = require('events'); | ||
| 7 | 8 | const { getSystemErrorName } = require('util'); | |
| 8 | 9 | const fixtures = require('../common/fixtures'); | |
| 9 | 10 | ||
@@ -69,5 +70,15 @@ const execOpts = { encoding: 'utf8', shell: true }; | |||
| 69 | 70 | ||
| 70 | 71 | execFile(process.execPath, [echoFixture, 0], { signal: 'hello' }, callback); | |
| 71 | 72 | }, { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' }); | |
| 73 | + } | ||
| 74 | + { | ||
| 75 | + // Verify that the process completing removes the abort listener | ||
| 76 | + const ac = new AbortController(); | ||
| 77 | + const { signal } = ac; | ||
| 72 | 78 | ||
| 79 | + const callback = common.mustCall((err) => { | ||
| 80 | + assert.strictEqual(getEventListeners(ac.signal).length, 0); | ||
| 81 | + assert.strictEqual(err, null); | ||
| 82 | + }); | ||
| 83 | + execFile(process.execPath, [fixture, 0], { signal }, callback); | ||
| 73 | 84 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments