Skip to content
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

Exit process on unhandled rejection #14220

Merged
merged 2 commits into from
Apr 22, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions app/lib/server/lib/meteorFixes.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,24 @@ Meteor.setInterval(() => {
_observeDriver._needToPollQuery();
});
}, interval);


/**
* If some promise is rejected and doesn't have a catch (unhandledRejection) it may cause this finally
* here https://github.com/meteor/meteor/blob/be6e529a739f47446950e045f4547ee60e5de7ae/packages/mongo/oplog_tailing.js#L348
* to not be executed never ending the oplog worked and frezing the entire process.
rodrigok marked this conversation as resolved.
Show resolved Hide resolved
*
* The only way to release the process is executing the following code via inspect:
* MongoInternals.defaultRemoteCollectionDriver().mongo._oplogHandle._workerActive = false
*
* Since unhandled rejections are deprecated in NodeJS:
* (node:83382) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections
* that are not handled will terminate the Node.js process with a non-zero exit code.
* we will start respecting this and exit the process to prevent these kind of problems.
*/

process.on('unhandledRejection', (error) => {
console.error(error);
console.error('Exiting due to an unhandled promise rejection');
process.exit(1);
});