Skip to content

Commit

Permalink
Exit process on unhandled rejection (#14220)
Browse files Browse the repository at this point in the history
* Exit process on uhandled rejection

* Update app/lib/server/lib/meteorFixes.js

Co-Authored-By: rodrigok <rodrigoknascimento@gmail.com>
  • Loading branch information
rodrigok authored and geekgonecrazy committed Apr 22, 2019
1 parent 77fe8ac commit 81be44e
Showing 1 changed file with 21 additions and 0 deletions.
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 worker and freezing the entire process.
*
* 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);
});

0 comments on commit 81be44e

Please sign in to comment.