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

dynamic import catch handler not firing on failure #2957

Closed
dnalborczyk opened this issue Jun 21, 2019 · 3 comments · Fixed by #2958
Closed

dynamic import catch handler not firing on failure #2957

dnalborczyk opened this issue Jun 21, 2019 · 3 comments · Fixed by #2958

Comments

@dnalborczyk
Copy link
Contributor

dnalborczyk commented Jun 21, 2019

  • Rollup Version: v1.15.6, v1.16.1
  • Operating System (or Browser): n/a
  • Node Version: v12.4.0

How Do We Reproduce?

import('./foo.js').catch((e) => {
  // catch error here
});

when bundled to commonjs:

// commonjs
Promise.resolve(require('./foo.js')).catch((e) => {
  // catch error here
  // will never execute if ./foo.js doesn't exist
})

Promise.resolve takes only a value, not an expression. I think rollup should either use:

Promise.resolve().then(() => require('./foo.js'))

or the Promise constructor:

new Promise((res) => res(require('./foo.js')))
@lukastaegert
Copy link
Member

lukastaegert commented Jun 22, 2019

Good point. Yes, an import error would not be caught by Promise.resolve.

@lukastaegert
Copy link
Member

Fix at #2958

@dnalborczyk
Copy link
Contributor Author

@lukastaegert awesome, thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants