fix(webpack): forward async load hook errors to the loader callback#610
fix(webpack): forward async load hook errors to the loader callback#610greymoth-jp wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe ChangesLoad Loader Error Handling
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The webpack
loadloader awaits the userloadhook but never catches a rejection. When aloadhook throws, the error escapes the loader function instead of being passed to webpack's loadercallback. Since the loader callsthis.async(), webpack's loader runner doesn't await the returned promise, so the throw surfaces as an unhandled promise rejection rather than a normal build error.The sibling loaders already forward the error to
callback:src/webpack/loaders/transform.tswraps the handler in try/catch and callscallback(error).src/rspack/loaders/load.tsgot the same handling in fix(rspack): prevents an unhandled promise rejection when throwing in the async loader #536.This wraps the webpack
loadloader the same way, and adds a unit test that mirrors the existingtransformloader error test. Reverting only the source change makes the new test fail (the rejection propagates out ofloadinstead of reaching the callback); with the change the webpack and rspack loader test files pass.Summary by CodeRabbit
Bug Fixes
Tests