-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
process: wait promise resolve before print result #52077
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ describe('--print with a promise', { concurrency: true }, () => { | |
code: 0, | ||
signal: null, | ||
stderr: '', | ||
stdout: 'Promise { 42 }\n', | ||
stdout: '42\n', | ||
}); | ||
}); | ||
|
||
|
@@ -29,7 +29,7 @@ describe('--print with a promise', { concurrency: true }, () => { | |
code: 0, | ||
signal: null, | ||
stderr: '', | ||
stdout: 'Promise { <pending> }\n', | ||
stdout: '42\n', | ||
}); | ||
}); | ||
|
||
|
@@ -43,7 +43,7 @@ describe('--print with a promise', { concurrency: true }, () => { | |
code: 0, | ||
signal: null, | ||
stderr: '', | ||
stdout: 'Promise { <pending> }\n', | ||
stdout: '', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it's acceptable. |
||
}); | ||
}); | ||
|
||
|
@@ -57,11 +57,11 @@ describe('--print with a promise', { concurrency: true }, () => { | |
code: 0, | ||
signal: null, | ||
stderr: '', | ||
stdout: 'Promise { <pending> }\n', | ||
stdout: '', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
}); | ||
}); | ||
|
||
it('should handle rejected promises', async () => { | ||
it('should handle rejected promises with unhandled-rejections=none', async () => { | ||
const result = await spawnPromisified(execPath, [ | ||
'--unhandled-rejections=none', | ||
'--print', | ||
|
@@ -72,11 +72,11 @@ describe('--print with a promise', { concurrency: true }, () => { | |
code: 0, | ||
signal: null, | ||
stderr: '', | ||
stdout: 'Promise { <rejected> 1 }\n', | ||
stdout: '', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. I would consider that change semver-major if we stick with it. |
||
}); | ||
}); | ||
|
||
it('should handle promises that reject after one tick', async () => { | ||
it('should handle promises that reject after one tick with unhandled-rejections=none', async () => { | ||
const result = await spawnPromisified(execPath, [ | ||
'--unhandled-rejections=none', | ||
'--print', | ||
|
@@ -87,7 +87,32 @@ describe('--print with a promise', { concurrency: true }, () => { | |
code: 0, | ||
signal: null, | ||
stderr: '', | ||
stdout: 'Promise { <pending> }\n', | ||
stdout: '', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
}); | ||
}); | ||
|
||
it('should error with unhandled rejected promises', async () => { | ||
const result = await spawnPromisified(execPath, [ | ||
'--print', | ||
'Promise.reject(1)', | ||
]); | ||
|
||
assert.strictEqual(result.code, 1); | ||
assert.strictEqual(result.signal, null); | ||
assert.strictEqual(result.stdout, ''); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
assert.ok(result.stderr.includes('ERR_UNHANDLED_REJECTION'), 'Not found ERR_UNHANDLED_REJECTION'); | ||
}); | ||
|
||
it('should error when throw inside fn', async () => { | ||
const result = await spawnPromisified(execPath, [ | ||
'--print', | ||
'Promise.resolve().then(()=>{throw new Error(10)})', | ||
]); | ||
|
||
assert.strictEqual(result.code, 1); | ||
assert.strictEqual(result.signal, null); | ||
assert.strictEqual(result.stdout, ''); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
assert.ok(result.stderr.includes('throw new Error(10)'), `Found: ${result.stderr}`); | ||
assert.ok(result.stderr.includes('Error: 10'), `Found: ${result.stderr}`); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concerns would be addressed if we removed the
await
here.