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

fix: prevent UnhandledPromiseRejectionWarning when module resolution/parsing fails #4228

Merged
merged 2 commits into from Sep 18, 2021

Conversation

kherock
Copy link
Contributor

@kherock kherock commented Sep 13, 2021

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes
  • no (see description)

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

List any relevant issue numbers:

resolves #4217

Description

This fixes an instance where rollup can cause an unhandled rejection during normal programmatic usage. There isn't a simple way to test this since as of Node 15, a test would amount to ensuring that the process doesn't exit when you force a module resolution error.

I temporarily enabled @typescript-eslint/no-floating-promises with parserServices to check if there were any other places that had floating promises outside of ModuleLoader.ts and saw the following:

npx eslint src --cache

/Users/kherock/Workspaces/rollup/src/ModuleLoader.ts
  341:3  error  Promises must be handled appropriately or explicitly marked as ignored with the `void` operator  @typescript-eslint/no-floating-promises

/Users/kherock/Workspaces/rollup/src/utils/queue.ts
  14:4  error  Promises must be handled appropriately or explicitly marked as ignored with the `void` operator  @typescript-eslint/no-floating-promises

/Users/kherock/Workspaces/rollup/src/watch/fileWatcher.ts
  19:3  error  Promises must be handled appropriately or explicitly marked as ignored with the `void` operator  @typescript-eslint/no-floating-promises
  21:4  error  Promises must be handled appropriately or explicitly marked as ignored with the `void` operator  @typescript-eslint/no-floating-promises
  30:4  error  Promises must be handled appropriately or explicitly marked as ignored with the `void` operator  @typescript-eslint/no-floating-promises

/Users/kherock/Workspaces/rollup/src/watch/watch-proxy.ts
  31:2  error  Promises must be handled appropriately or explicitly marked as ignored with the `void` operator  @typescript-eslint/no-floating-promises

/Users/kherock/Workspaces/rollup/src/watch/watch.ts
  97:4  error  Promises must be handled appropriately or explicitly marked as ignored with the `void` operator  @typescript-eslint/no-floating-promises

✖ 7 problems (7 errors, 0 warnings)

I didn't notice anything else that seemed dangerous, all the other cases were either already handled imperatively or were innocuous .close() calls that would only marginally benefit from a handler which logs a warning.

@kherock kherock changed the title fix: prevent UnhandledPromiseRejectionWarning from module resolution/parsing fails fix: prevent UnhandledPromiseRejectionWarning when module resolution/parsing fails Sep 14, 2021
@codecov
Copy link

codecov bot commented Sep 18, 2021

Codecov Report

Merging #4228 (ce1cd4d) into master (bce7624) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #4228   +/-   ##
=======================================
  Coverage   98.37%   98.37%           
=======================================
  Files         202      202           
  Lines        7260     7260           
  Branches     2119     2119           
=======================================
  Hits         7142     7142           
  Misses         58       58           
  Partials       60       60           
Impacted Files Coverage Δ
src/ModuleLoader.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bce7624...ce1cd4d. Read the comment docs.

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

Successfully merging this pull request may close these issues.

Rollup creates an UnhandledPromiseRejectionWarning when module parsing fails
2 participants