Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
kanongil committed Dec 31, 2018
1 parent cfd143a commit 29b7fd9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2015 - 2017, Gil Pedersen <gpdev@gpost.dk>
Copyright (c) 2015 - 2019, Gil Pedersen <gpdev@gpost.dk>
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Expand Down
3 changes: 3 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ exports.Manager = class {
if (startError) {
throw new Error('Start aborted');
}

active.push(server);
}
catch (err) {
Expand Down Expand Up @@ -334,9 +335,11 @@ exports.reset = function () {
if (internals.processExit) {
internals.teardownExitHooks();
}

if (internals.manager) {
clearTimeout(internals.manager.exitTimer);
}

internals.manager = null;
};

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
"devDependencies": {
"code": "^5.1.0",
"hapi": "^17.0.0",
"lab": "^15.0.0"
"lab": "^18.0.1"
},
"dependencies": {
"bounce": "^1.2.0",
"hoek": "^5.0.0"
"hoek": "^6.1.2"
},
"peerDependencies": {
"hapi": ">=17.0.0"
Expand Down
32 changes: 23 additions & 9 deletions test/exiting.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,25 @@ describe('Manager', () => {
return promise;
};

const ignoreProcessExitError = (err) => {

if (err instanceof Exiting.ProcessExitError) {
return;
}

throw err;
};

lab.before(() => {

// Silence log messages

const log = Exiting.log;
Exiting.log = function () {
Exiting.log = function (...args) {

const consoleError = console.error;
console.error = Hoek.ignore;
log.apply(Exiting, arguments);
log.apply(Exiting, args);
console.error = consoleError;
};
});
Expand Down Expand Up @@ -228,9 +237,7 @@ describe('Manager', () => {
exited.exit(0);
});

it('uncaughtException handler ignores ProcessExitErrors', async () => {

process.removeAllListeners('uncaughtException'); // Disable lab integration
it('uncaughtException handler ignores ProcessExitErrors', async (flags) => {

const manager = Exiting.createManager([Hapi.Server(), Hapi.Server(), Hapi.Server()]);
const exited = grabExit(manager, true);
Expand All @@ -239,23 +246,30 @@ describe('Manager', () => {

// Immitate a throw by faking an uncaughtException

flags.onUncaughtException = ignoreProcessExitError;
process.emit('uncaughtException', new Exiting.ProcessExitError());

const { code, state } = await exited.exit(0);
expect(state).to.equal('stopped');
expect(code).to.equal(0);
});

it('unhandledRejection handler ignores ProcessExitErrors', async () => {

process.removeAllListeners('unhandledRejection'); // Disable lab integration
it('unhandledRejection handler ignores ProcessExitErrors', async (flags) => {

const manager = Exiting.createManager([Hapi.Server(), Hapi.Server(), Hapi.Server()]);
const exited = grabExit(manager, true);

await manager.start();

new Promise((resolve, reject) => reject(new Exiting.ProcessExitError()));
await new Promise((resolve, reject) => {

flags.onUnhandledRejection = (err) => {

(err instanceof Exiting.ProcessExitError) ? resolve() : reject(err);
};

Promise.reject(new Exiting.ProcessExitError());
});

const { code, state } = await exited.exit(0);
expect(state).to.equal('stopped');
Expand Down

0 comments on commit 29b7fd9

Please sign in to comment.