Skip to content

Commit

Permalink
wip - actively decorate errors from importing hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
jkrems committed Jan 7, 2020
1 parent 56b7478 commit 0b14f5d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 15 deletions.
3 changes: 2 additions & 1 deletion lib/internal/modules/esm/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ const defaultLoaderWorker = {

const userModule = esmLoader.ESMLoader.importWrapped(workerData.loaderHREF).catch(
(err) => {
// console.error({err})
const { decorateErrorStack } = require('internal/util');
decorateErrorStack(err);
internalBinding('errors').triggerUncaughtException(
err,
true /* fromPromise */
Expand Down
29 changes: 18 additions & 11 deletions test/message/esm_loader_not_found.out
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
(node:*) ExperimentalWarning: The ESM module loader is experimental.
(node:*) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
internal/modules/esm/resolve.js:*
let url = moduleWrapResolve(specifier, parentURL);
^
(node:*) ExperimentalWarning: The ESM module loader is experimental.

events.js:*
throw er; // Unhandled 'error' event
^
Error: Cannot find package 'i-dont-exist' imported from *
at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:*:*)
at defaultResolve (internal/modules/esm/resolve.js:*:*)
at Object.resolveImportURL (internal/modules/esm/loader.js:*:*)
at Loader.resolve (internal/modules/esm/loader.js:*:*)
at Loader.getModuleJob (internal/modules/esm/loader.js:*:*)
at Loader.import (internal/modules/esm/loader.js:*:*)
at internal/process/esm_loader.js:*:*
at Object.initializeLoader (internal/process/esm_loader.js:*:*)
at runMainESM (internal/modules/run_main.js:*:*)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:*:*)
at internal/main/run_main_module.js:*:* {
at Loader.importWrapped (internal/modules/esm/loader.js:*:*)
at internal/modules/esm/worker.js:*:*
at NativeModule.compileForInternalLoader (internal/bootstrap/loaders.js:*:*)
at nativeModuleRequire (internal/bootstrap/loaders.js:*:*)
at MessagePort.<anonymous> (internal/main/worker_thread.js:*:*)
at MessagePort.emit (events.js:*:*)
Emitted 'error' event on Worker instance at:
at Worker.[kOnErrorMessage] (internal/worker.js:*:*)
at Worker.[kOnMessage] (internal/worker.js:*:*)
at MessagePort.<anonymous> (internal/worker.js:*:*)
at MessagePort.emit (events.js:*:*)
at MessagePort.onmessage (internal/worker/io.js:*:*) {
code: 'ERR_MODULE_NOT_FOUND'
}
15 changes: 12 additions & 3 deletions test/message/esm_loader_syntax_error.out
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
(node:*) ExperimentalWarning: The ESM module loader is experimental.
(node:*) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
file://*/test/fixtures/es-module-loaders/syntax-error.mjs:2
(node:*) ExperimentalWarning: The ESM module loader is experimental.

events.js:*
throw er; // Unhandled 'error' event
^
file:///*/test/fixtures/es-module-loaders/syntax-error.mjs:2
await async () => 0;
^^^^^

SyntaxError: Unexpected reserved word
at Loader.moduleStrategy (internal/modules/esm/translators.js:*:*)
at async link (internal/modules/esm/module_job.js:*:*)
Emitted 'error' event on Worker instance at:
at Worker.[kOnErrorMessage] (internal/worker.js:*:*)
at Worker.[kOnMessage] (internal/worker.js:*:*)
at MessagePort.<anonymous> (internal/worker.js:*:*)
at MessagePort.emit (events.js:*:*)
at MessagePort.onmessage (internal/worker/io.js:*:*)

0 comments on commit 0b14f5d

Please sign in to comment.