@tus/s3-store: failed part upload crashes entire server
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- aws, typescript
Research direction
Start in packages/s3-store/src/index.ts at the deferred promises around lines 421 and 440, then inspect packages/server/src/server.ts around line 188 to trace rejection handling. Reproduce an uploadPart or uploadIncompletePart rejection, including permit.release() failures, and verify that the server remains running while the current upload returns HTTP 500.
Written by the indexing model from the issue text.
Description
When uploadPart or uploadIncompletePart throws (is rejected) entire server crashes. This happens often with Scaleway Object Storage as their service fails with error 500 with non-informative console message An error was encountered in a non-retryable streaming request. from AWS library. After listening for unhandledRejection event I got some more information.
Unhandled Rejection at: Promise {
<rejected> S3ServiceException [InternalError]: We encountered an internal error. Please try again.
at throwDefaultError (/app/node_modules/@smithy/smithy-client/dist-cjs/index.js:867:20)
at /app/node_modules/@smithy/smithy-client/dist-cjs/index.js:876:5
at de_CommandError (/app/node_modules/@aws-sdk/client-s3/dist-cjs/index.js:4965:14)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /app/node_modules/@smithy/middleware-serde/dist-cjs/index.js:35:20
at async /app/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js:483:18
at async /app/node_modules/@smithy/middleware-retry/dist-cjs/index.js:321:38
at async /app/node_modules/@aws-sdk/middleware-flexible-checksums/dist-cjs/index.js:315:18
at async /app/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js:109:22
at async /app/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js:136:14 {
'$fault': 'client',
'$metadata': {
httpStatusCode: 500,
requestId: 'txg5c09a7e2fbe14ba89375-0067aa0421',
extendedRequestId: 'txg5c09a7e2fbe14ba89375-0067aa0421',
cfId: undefined
},
Code: 'InternalError',
RequestId: 'txg5c09a7e2fbe14ba89375-0067aa0421',
HostId: 'txg5c09a7e2fbe14ba89375-0067aa0421',
Resource: '<s3-object-key>.bin'
},
I believe the problem is that when a deferred promise is created it does not handle rejections. It is only inserted into a list.
https://github.com/tus/tus-node-server/blob/81eb03a82658b2e5e97abdb05c26418192320724/packages/s3-store/src/index.ts#L421
At the end promises are aggregated with Promise.all and returned to the caller where an rejection handler is eventually added.
https://github.com/tus/tus-node-server/blob/81eb03a82658b2e5e97abdb05c26418192320724/packages/s3-store/src/index.ts#L440
https://github.com/tus/tus-node-server/blob/81eb03a82658b2e5e97abdb05c26418192320724/packages/server/src/server.ts#L188
During this period if any of the promises in a list are rejected, the rejection is not handled.
Steps to reproduce
Use S3 server that sometimes throws errors (e.g. Scaleway Object Storage) or manually throw error. I modified uploadPart(metadata, readStream, partNumber) to randomly reject. Add provided snippet at the top of this function. This will result in server crash.
const errorProbability = Math.random()
if (errorProbability < 0.2) {
return new Promise((resolve, reject) => {
setTimeout(() => {
reject(new Error('test'));
}, 1000);
})
}
Expected behavior
Server should not crash. Failed part upload should end the current upload with HTTP 500 Internal Server Error status code.
Observation
Promises (rejections) returned by acquiredPermit?.release() and permit?.release() are also not handled and would cause server to crash.
- Dominant language
- TypeScript
- Stars
- 1.1k
- Forks
- 227
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 10
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from tus/tus-node-server
-
Difficulty 3/5 1-2 days Newbie friendliness 64/100
tus/tus-node-server#884 · 1 comment ·
Maintainers usually reply within 2 days
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 42/100
tus/tus-node-server#807 ·
Maintainers usually reply within 2 days
-
Datastore dynamicOpen
Difficulty 5/5 Over a week Newbie friendliness 25/100
tus/tus-node-server#737 · 3 comments · 1 reaction ·
Maintainers usually reply within 2 days
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
tus/tus-node-server#521 · 2 comments ·
Maintainers usually reply within 2 days
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
tus/tus-node-server#380 · 7 comments ·
Maintainers usually reply within 2 days
All issues in tus/tus-node-server
Similar issues
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 82/100
lingdojo/kana-dojo#34714 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 70/100
-
needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
manaflow-ai/cmux#59692 ·
Maintainers usually reply within 1 day
-
Retire stale Python-parity labels in Rust ingress and auth testsPossibly taken @github-actions claimed this today. Openfactory factory:building factory:unowned ralph-status:in-progress via:opencode-free/hy4-flash-free
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
JoshCLWren/comic-pile#5874 · 2 comments ·
Maintainers usually reply within 1 day
-
area: community lane: free-agent priority: P1 roadmap type: task
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
velella-sh/offing#1046 ·
Maintainers usually reply within 1 day