From 94ebf3f0a733902477674d6cc945ad052755bb28 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Mon, 28 Jan 2019 16:52:23 +0100 Subject: [PATCH] module: silence ModuleJob unhandled rejection warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This could otherwise print unhandled rejection warnings if the process does not exit immediately inside an earlier `.catch()` handler. PR-URL: https://github.com/nodejs/node/pull/25769 Reviewed-By: Ruben Bridgewater Reviewed-By: Gus Caplan Reviewed-By: Michaƫl Zasso Reviewed-By: Guy Bedford Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- lib/internal/modules/esm/module_job.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/internal/modules/esm/module_job.js b/lib/internal/modules/esm/module_job.js index fbb29aef783006..e3fb91ca6ff505 100644 --- a/lib/internal/modules/esm/module_job.js +++ b/lib/internal/modules/esm/module_job.js @@ -6,6 +6,8 @@ const { decorateErrorStack } = require('internal/util'); const assert = require('assert'); const resolvedPromise = SafePromise.resolve(); +function noop() {} + /* A ModuleJob tracks the loading of a single Module, and the ModuleJobs of * its dependencies, over time. */ class ModuleJob { @@ -41,6 +43,9 @@ class ModuleJob { }; // Promise for the list of all dependencyJobs. this.linked = link(); + // This promise is awaited later anyway, so silence + // 'unhandled rejection' warnings. + this.linked.catch(noop); // instantiated == deep dependency jobs wrappers instantiated, // module wrapper instantiated