-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
Refactor test http exceptions #18506
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
Changes from 1 commit
f802a56
4cd8fbc
4286f71
1eb069c
7ad8ce7
6f125e1
0060979
6840cf3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,11 +20,13 @@ | |
| // USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
|
||
| 'use strict'; | ||
| require('../common'); | ||
| const common = require('../common'); | ||
| const Countdown = require('../common/countdown'); | ||
| const http = require('http'); | ||
| const NUMBER_OF_EXCEPTIONS = 4; | ||
| const countdown = new Countdown(NUMBER_OF_EXCEPTIONS, () => process.exit(0)); | ||
| const countdown = new Countdown(NUMBER_OF_EXCEPTIONS, () => { | ||
| process.exit(0); | ||
| }); | ||
|
|
||
| const server = http.createServer(function(req, res) { | ||
| intentionally_not_defined(); // eslint-disable-line no-undef | ||
|
|
@@ -33,15 +35,18 @@ const server = http.createServer(function(req, res) { | |
| res.end(); | ||
| }); | ||
|
|
||
| function onUncaughtException(err) { | ||
| console.log(`Caught an exception: ${err}`); | ||
| if (err.name === 'AssertionError') throw err; | ||
| countdown.dec(); | ||
| } | ||
|
|
||
| process.on('uncaughtException', | ||
| common.mustCall(onUncaughtException, NUMBER_OF_EXCEPTIONS) | ||
| ); | ||
|
Contributor
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. Can this be brought up to the previous line? The dangling
Contributor
Author
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. sadly it cant be moved up since it will break the linter due to reaching the max limit of 80 characters in one line
Contributor
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. It's only 70 chars as far as I can tell? |
||
|
|
||
| server.listen(0, function() { | ||
| for (let i = 0; i < NUMBER_OF_EXCEPTIONS; i += 1) { | ||
| http.get({ port: this.address().port, path: `/busy/${i}` }); | ||
| } | ||
| }); | ||
|
|
||
| process.on('uncaughtException', function(err) { | ||
| console.log(`Caught an exception: ${err}`); | ||
| if (err.name === 'AssertionError') throw err; | ||
| countdown.dec(); | ||
| }); | ||
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.
Does
server.close()not do the trick here?Uh oh!
There was an error while loading. Please reload this page.
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.
it does not, probably because of the intended exception throwing
intentionally_not_defined. it keepsresfrom being closed with.end();.