@tus/s3-store: ensure promise rejection isn't uncaught#812
@tus/s3-store: ensure promise rejection isn't uncaught#812
Conversation
🦋 Changeset detectedLatest commit: f983077 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughChanges were made to prevent unhandled promise rejections in the S3Store's Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
This PR fixes a fairly rare uncaught exception issue that I've had occur in production resulting in a fatal error / node crash. I can reproduce this locally by doing TUS uploads and intentionally disrupting traffic to S3.
This issue occurs when one of the deferred promises throws before getting to the Promise.all which node identifies as an uncaught exception. This only happens if
pendingChunkFilepathis not null in the catch block which causes the async operationawait fsProm.rm(pendingChunkFilepath)to run which advances the event loop causing node to recognize the uncaught exception before Promise.all is awaited.I've also added a test that reproduces the issue consistently. You can comment out my fix and run the new test to see the uncaught exception.