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

esm loader error not catchable #24175

Closed
franher opened this issue Nov 6, 2018 · 7 comments
Closed

esm loader error not catchable #24175

franher opened this issue Nov 6, 2018 · 7 comments
Labels
code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. esm Issues and PRs related to the ECMAScript Modules implementation. test Issues and PRs related to the tests.

Comments

@franher
Copy link
Contributor

franher commented Nov 6, 2018

  • Version: master
  • Platform: all
  • Subsystem: esm

For code-learn at NodeCONF EU we wrote a new test case to cover https://coverage.nodejs.org/coverage-d32b5bd567544f5b/root/internal/bootstrap/loaders.js.html#L152 . After that, the test case generates the error but we can't catch it.

PR with the test case ready to land as soon this issue is resolved: #24183

@devsnek
Copy link
Member

devsnek commented Nov 6, 2018

resolution errors are "early" errors, meaning they occur before evaluation. to test this you can spawn a child process and test the stdout.

nvm i see what you mean now, i'm looking into it.

@devsnek devsnek added test Issues and PRs related to the tests. code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. esm Issues and PRs related to the ECMAScript Modules implementation. labels Nov 6, 2018
@franher
Copy link
Contributor Author

franher commented Nov 6, 2018

PR with the test case ready to land as soon this issue is resolved: #24183

@mhdawson
Copy link
Member

mhdawson commented Nov 6, 2018

@MylesBorins who is the best person to ask to take a look at this to confirm if our understanding that this is a bug is correct?

@devsnek
Copy link
Member

devsnek commented Nov 6, 2018

@mhdawson i'm looking into it now. i can confirm that not being able to catch() this is a bug.

@mhdawson
Copy link
Member

mhdawson commented Nov 6, 2018

@devsnek thanks!

@devsnek
Copy link
Member

devsnek commented Nov 6, 2018

weee okay so the problem is the resolve hook. the actual error being generated is (as i said earlier by coincidence) an early error. it is trying to resolve the test file, but since the resolve hook just returns an empty string, it won't work.

if the loader is changed to this it works cc @franher

export async function resolve(specifier, parent, defaultResolve) {
  if (specifier === 'does_not_exist') {
    return { url: 'does_not_exist', format: 'builtin' };
  }
  return defaultResolve(specifier, parent);
}

@franher
Copy link
Contributor Author

franher commented Nov 6, 2018

ohh I see @devsnek Thank you for your support.

I've just pushed the changes to the PR with the proper resolve hook.

I close this issue.

@franher franher closed this as completed Nov 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. esm Issues and PRs related to the ECMAScript Modules implementation. test Issues and PRs related to the tests.
Projects
None yet
Development

No branches or pull requests

3 participants