fix(lib-storage): pass abortSignal to single-part PutObject (#5109) - #7992
Open
mohanrajvenkatesan23-04 wants to merge 1 commit into
Open
Conversation
When lib-storage's Upload falls into the single-part path
(__uploadUsingPut), the underlying client.send(new PutObjectCommand(...))
call did not forward the upload's abortController.signal. Calling
upload.abort() mid-flight caused done() to reject (via the existing
Promise.race against __abortTimeout), but the in-flight HTTP PUT
continued to completion and the file was still written to S3.
Pass { abortSignal: this.abortController.signal } as the second
argument to client.send(...) so the in-flight PUT is cancelled at the
HTTP layer when the user calls upload.abort(), matching the behavior
already wired up for the multipart path.
Fixes aws#5109
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Fixes #5109
Description
lib-storage'sUploadexposes anabort()method backed by an internalAbortController. For multipart uploads this controller is wired into theUploadPartCommand/CreateMultipartUploadCommandcalls, so callingupload.abort()mid-flight cancels the in-flight HTTP requests.For the single-part path (
__uploadUsingPut, around line 168 ofUpload.ts), however, the underlying call was:with no second argument. As a result, calling
upload.abort()mid-flight causeddone()to reject (via the existingPromise.raceagainst__abortTimeout(this.abortController.signal)), but the in-flight HTTPPUTcontinued to completion and the file was still written to S3 — exactly the bug reported in #5109.This PR passes the standard SDK option
{ abortSignal: this.abortController.signal }as the second argument toclient.send(...)in__uploadUsingPut, so the in-flightPUTis cancelled at the HTTP layer when the user callsupload.abort(). Net production diff is 4 lines and reuses the controller already present on the class.Files changed:
lib/lib-storage/src/Upload.ts(+4 net lines) — passabortSignalthrough toclient.send.lib/lib-storage/src/Upload.spec.ts(+~56 lines) — two regression tests, see Testing.Testing
Two regression tests added in
lib/lib-storage/src/Upload.spec.ts:should pass abortSignal to client.send for single-part (PutObject) uploads (#5109)— directly assertsclient.sendis invoked with{ abortSignal }matching the upload's controller. Pre-fix this test fails (the second arg wasundefined); post-fix it passes.should abort an in-flight single-part (PutObject) upload (#5109)— uses a mockedclient.sendthat resolves only when itsabortSignalis aborted. AfterabortController.abort()is called mid-flight, assertsupload.done()rejects withname: "AbortError". This is the user-observable behavior the reporter wanted.Local verification:
tsc --noEmit -p tsconfig.jsonintroduces zero new errors versus baseline.lib/lib-storageis blocked by a pre-existing workspace-build / Yarn-on-Windows-with-spaces issue (workspacedist-*/not built locally and unrelated@aws-sdk/client-s3module-resolution warnings), so test execution is being deferred to CI, which will validate both the new tests and the existing suite.Checklist
*.integ.spec.ts) or E2E tests.@public,@internaltags and enabled doc generation on the package. Remember that access level annotations go below the description, not above.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
generated by AI tools, and reviewed by Mohanraj Venkatesan