forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib,src: throw on unhanded promise rejections
Refs: nodejs#12010 Refs: nodejs#5292 Refs: nodejs/promises#26 Refs: nodejs#6355 PR-URL: nodejs#6375
- Loading branch information
1 parent
b2c7a51
commit f6e35fe
Showing
15 changed files
with
172 additions
and
114 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,26 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
|
||
const p1 = new Promise((res, rej) => { | ||
consol.log('One'); // eslint-disable-line no-undef | ||
}); | ||
|
||
const p2 = new Promise((res, rej) => { // eslint-disable-line no-unused-vars | ||
consol.log('Two'); // eslint-disable-line no-undef | ||
}); | ||
|
||
const p3 = new Promise((res, rej) => { | ||
consol.log('Three'); // eslint-disable-line no-undef | ||
}); | ||
|
||
new Promise((res, rej) => { | ||
setTimeout(common.mustCall(() => { | ||
p1.catch(() => {}); | ||
p3.catch(() => {}); | ||
}), 1); | ||
}); | ||
|
||
process.on('uncaughtException', (err) => | ||
common.fail('Should not trigger uncaught exception')); | ||
|
||
process.on('exit', () => process._rawDebug('exit event emitted')); |
This file contains 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,16 @@ | ||
exit event emitted | ||
*test*message*promise_fast_handled_reject.js:* | ||
consol.log('One'); // eslint-disable-line no-undef | ||
^ | ||
|
||
ReferenceError: consol is not defined | ||
at Promise (*test*message*promise_fast_handled_reject.js:*:*) | ||
at Promise (<anonymous>) | ||
at Object.<anonymous> (*test*message*promise_fast_handled_reject.js:*:*) | ||
at Module._compile (module.js:*:*) | ||
at Object.Module._extensions..js (module.js:*:*) | ||
at Module.load (module.js:*:*) | ||
at tryModuleLoad (module.js:*:*) | ||
at Function.Module._load (module.js:*:*) | ||
at Function.Module.runMain (module.js:*:*) | ||
at startup (bootstrap_node.js:*:*) |
This file contains 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,18 @@ | ||
'use strict'; | ||
|
||
// We should always have the stacktrace of the oldest rejection. | ||
|
||
const common = require('../common'); | ||
|
||
new Promise(function(res, rej) { | ||
consol.log('One'); // eslint-disable-line no-undef | ||
}); | ||
|
||
new Promise(function(res, rej) { | ||
consol.log('Two'); // eslint-disable-line no-undef | ||
}); | ||
|
||
process.on('uncaughtException', (err) => | ||
common.fail('Should not trigger uncaught exception')); | ||
|
||
process.on('exit', () => process._rawDebug('exit event emitted')); |
This file contains 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,16 @@ | ||
exit event emitted | ||
*test*message*promise_fast_reject.js:* | ||
consol.log('One'); // eslint-disable-line no-undef | ||
^ | ||
|
||
ReferenceError: consol is not defined | ||
at *test*message*promise_fast_reject.js:*:* | ||
at Promise (<anonymous>) | ||
at Object.<anonymous> (*test*message*promise_fast_reject.js:*:*) | ||
at Module._compile (module.js:*:*) | ||
at Object.Module._extensions..js (module.js:*:*) | ||
at Module.load (module.js:*:*) | ||
at tryModuleLoad (module.js:*:*) | ||
at Function.Module._load (module.js:*:*) | ||
at Function.Module.runMain (module.js:*:*) | ||
at startup (bootstrap_node.js:*:*) |
This file contains 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,18 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
|
||
|
||
Promise.reject(new Error('oops')); | ||
|
||
setImmediate(() => { | ||
common.fail('Should not reach Immediate'); | ||
}); | ||
|
||
process.on('beforeExit', () => | ||
common.fail('beforeExit should not be reached')); | ||
|
||
process.on('uncaughtException', (err) => { | ||
common.fail('Should not trigger uncaught exception'); | ||
}); | ||
|
||
process.on('exit', () => process._rawDebug('exit event emitted')); |
This file contains 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,15 @@ | ||
exit event emitted | ||
*test*message*promise_reject.js:* | ||
Promise.reject(new Error('oops')); | ||
^ | ||
|
||
Error: oops | ||
at *test*message*promise_reject.js:*:* | ||
at Module._compile (module.js:*:*) | ||
at Object.Module._extensions..js (module.js:*:*) | ||
at Module.load (module.js:*:*) | ||
at tryModuleLoad (module.js:*:*) | ||
at Function.Module._load (module.js:*:*) | ||
at Function.Module.runMain (module.js:*:*) | ||
at startup (bootstrap_node.js:*:*) | ||
at bootstrap_node.js:*:* |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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,19 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
|
||
// Flags: --expose-gc | ||
|
||
const p = new Promise((res, rej) => { | ||
consol.log('oops'); // eslint-disable-line no-undef | ||
}); | ||
|
||
// Manually call GC due to possible memory contraints with attempting to | ||
// trigger it "naturally". | ||
process.nextTick(common.mustCall(() => { | ||
p.catch(() => {}); | ||
/* eslint-disable no-undef */ | ||
gc(); | ||
gc(); | ||
gc(); | ||
/* eslint-enable no-undef */ | ||
}, 1)); |
This file contains 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
Oops, something went wrong.