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

Missing useful debug information for Dynamic Import errors #19763

Closed
m-a-r-c-e-l-i-n-o opened this issue Apr 3, 2018 · 2 comments
Closed

Missing useful debug information for Dynamic Import errors #19763

m-a-r-c-e-l-i-n-o opened this issue Apr 3, 2018 · 2 comments
Labels
confirmed-bug Issues with confirmed bugs. esm Issues and PRs related to the ECMAScript Modules implementation.

Comments

@m-a-r-c-e-l-i-n-o
Copy link

Hello there,

Node: v9.10.1
Platform: Darwin MACLTUS44977 15.6.0 Darwin Kernel Version 15.6.0

// problem.mjs
const foo = () => {
  await bar()
}

So "problem.mjs" has an issue, which is that it is using the "await" keyword inside a non "async" function.

If you try to run this file as an entry in node or regular import, a very helpful error is thrown as expected:

// "node --experimental-modules problem.mjs" or "import problem from './problem.mjs'"
file:///Users/ctsuser1/Desktop/projects/problem.mjs:2
  await bar()
  ^^^^^
SyntaxError: Unexpected reserved word
    at translators.set (internal/loader/Translators.js:27:13)
    at <anonymous>

But... if you try to "dynamically" import "problem.mjs", it throws a completely useless error:

SyntaxError: Unexpected reserved word
    at translators.set (internal/loader/Translators.js:27:13)
    at <anonymous>

Is this a bug? How can this be resolved? It's impossible to debug this way. Thanks in advance!

@m-a-r-c-e-l-i-n-o m-a-r-c-e-l-i-n-o changed the title Missing Stack Trace for Dynamic Import Missing useful debug information for Dynamic Import errors Apr 3, 2018
@devsnek
Copy link
Member

devsnek commented Apr 3, 2018

i think once we standardise our use of module errors in ModuleJob we can streamline decorating the error stack but i'll have to look into it more

@jasnell
Copy link
Member

jasnell commented Jun 19, 2020

No activity on this for over 2 years, closing

@jasnell jasnell closed this as completed Jun 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. esm Issues and PRs related to the ECMAScript Modules implementation.
Projects
None yet
Development

No branches or pull requests

3 participants