-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
child_process: allow promisified exec to be cancel #34249
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
Closed
metcoder95
wants to merge
25
commits into
nodejs:master
from
metcoder95:cancel-promisified-child-process
Closed
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
eed3f17
child_process: allow promisified exec to be cancel
metcoder95 0ef841d
child_process: fix validation issue
metcoder95 70cb86c
child_process: use Primordials instead of plain Promise
metcoder95 a6ae623
child_process: refactor according to review
metcoder95 988ea3f
child_process: remove license from test
metcoder95 78e7521
child_process: improve testing
metcoder95 c8210f6
child_process: fix linter issues
metcoder95 3dca212
child_process: check if AbortSignal is aborted before rejecting/resol…
metcoder95 4163c44
child_process: check for signal before looking is aborted
metcoder95 9e3291e
child_process: refactor signal to use spawn function
metcoder95 3b14ebe
child_process: fix linter issues
metcoder95 087f924
child_process: revert check for extra callback
metcoder95 0fd0719
child_process: fix double AbortError emit
metcoder95 a41ac9a
child_process: fix linter issues
metcoder95 f9af3fd
child_process: fix fork issue with AbortController
metcoder95 2b19cd5
child_process: remove whitespace
metcoder95 f642015
child_process: re-order alphabetically the options
metcoder95 dade71b
child_process: refactor spawnWithSignal
metcoder95 5e7aa7d
child_process: remove wrapper function
metcoder95 2305734
child_process: revert refactor to spawn
metcoder95 a60b935
child_process: fix tests
metcoder95 fe077b0
child_process: refactor
metcoder95 72ff68a
child_process: refactor tests
metcoder95 026021a
child_process: refactor listeners args
metcoder95 c093035
child_process: inline listener
metcoder95 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
child_process: allow promisified exec to be cancel
Using new experimental AbortController, add support for promisified exec to be cancelled.
- Loading branch information
commit eed3f17252f0da5a823e6a68d6e4a1a656a2d44a
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
test/parallel/test-child-process-exec-abortcontroller-promisified.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| // Copyright Joyent, Inc. and other Node contributors. | ||
| // | ||
| // Permission is hereby granted, free of charge, to any person obtaining a | ||
| // copy of this software and associated documentation files (the | ||
| // "Software"), to deal in the Software without restriction, including | ||
| // without limitation the rights to use, copy, modify, merge, publish, | ||
| // distribute, sublicense, and/or sell copies of the Software, and to permit | ||
| // persons to whom the Software is furnished to do so, subject to the | ||
| // following conditions: | ||
| // | ||
| // The above copyright notice and this permission notice shall be included | ||
| // in all copies or substantial portions of the Software. | ||
| // | ||
| // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
| // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
| // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
| // USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
|
||
|
metcoder95 marked this conversation as resolved.
Outdated
|
||
| 'use strict'; | ||
| const common = require('../common'); | ||
| const assert = require('assert'); | ||
| const exec = require('child_process').exec; | ||
| const { promisify } = require('util'); | ||
|
|
||
| let pwdcommand, dir; | ||
| const execPromisifed = promisify(exec); | ||
|
|
||
| if (common.isWindows) { | ||
| pwdcommand = 'echo %cd%'; | ||
| dir = 'c:\\windows'; | ||
| } else { | ||
| pwdcommand = 'pwd'; | ||
| dir = '/dev'; | ||
| } | ||
|
|
||
|
|
||
| { | ||
| const ac = new AbortController(); | ||
| const signal = ac.signal; | ||
| assert.rejects(execPromisifed(pwdcommand, { cwd: dir, signal }), /AbortError/); | ||
| ac.abort(); | ||
| } | ||
|
|
||
| { | ||
| assert.rejects(execPromisifed(pwdcommand, { cwd: dir, signal: {} }), { | ||
| code: 'ERR_INVALID_ARG_TYPE', | ||
| name: 'TypeError', | ||
| message: 'The "options.signal" property must be an ' + | ||
| 'instance of AbortSignal. Received an instance of Object' | ||
| }); | ||
| } | ||
|
|
||
| { | ||
| function signal() {} | ||
| assert.rejects(execPromisifed(pwdcommand, { cwd: dir, signal }), { | ||
| code: 'ERR_INVALID_ARG_TYPE', | ||
| name: 'TypeError', | ||
| message: 'The "options.signal" property must be an ' + | ||
| 'instance of AbortSignal. Received function signal' | ||
| }); | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.