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

error thrown being supressed in favour of "unfinished hook action(s)" message #4408

Closed
samualtnorman opened this issue Feb 16, 2022 · 1 comment · Fixed by #4409
Closed

Comments

@samualtnorman
Copy link

Rollup Version

2.67.2

Operating System (or Browser)

Manjaro Linux

Node Version (if applicable)

v17.4.0

Link To Reproduction

https://github.com/samualtnorman/rollup-minimal-issue-repro

Expected Behaviour

the minimal example is bundling using the @rollup/plugin-json, @rollup/plugin-json, @rollup/plugin-commonjs, and a minimal example of a dodgy (my) plugin that just has a transform hook that throws an error (:() on the second call

I would expect to see the error thrown in the console alongside the "unfinished hook action(s)" message

Actual Behaviour

only the "unfinished hook action(s)" message appears in the console, which made debugging really, really fun

> node .
[!] Error: unfinished hook action(s) on exit:
(node-resolve) resolveId "@rollup/plugin-commonjs" "/home/samual/temp/rollup-test/index.js"
(node-resolve) resolveId "@rollup/plugin-json" "/home/samual/temp/rollup-test/index.js"
@lukastaegert
Copy link
Member

lukastaegert commented Feb 18, 2022

Thanks for the nice repro. I recently saw this myself but could not really find a good reproduction as it only occurred in an Ava test but not e.g. in Rollup CLI. I added a fix to #4409. Apparently, using top-level-await is one of the few ways to really do this without getting the error anyway as an "unhandledPromiseRejection".

In short, calling process.exit(1) in a process.on('exit', ...) handler is a bad idea as it can swallow other "cleanup" actions. Instead, I now set process.exitCode = 1, which has the same effect of ensuring we get an error on exit, but nothing is swallowed.

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