File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
frontend/src/common/services/storage Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -155,11 +155,18 @@ export class S3StorageService {
155155 signal . addEventListener ( 'abort' , abortHandler ) ;
156156 } ) ;
157157
158- // Create a race between the upload and abortion
159- await Promise . race ( [
160- this . s3Client . send ( new PutObjectCommand ( uploadParams ) ) ,
161- abortPromise
162- ] ) ;
158+ try {
159+ // Create a race between the upload and abortion
160+ await Promise . race ( [
161+ this . s3Client . send ( new PutObjectCommand ( uploadParams ) ) ,
162+ abortPromise
163+ ] ) ;
164+ } finally {
165+ // Clean up the event listener to prevent memory leaks
166+ if ( abortHandler && signal ) {
167+ signal . removeEventListener ( 'abort' , abortHandler ) ;
168+ }
169+ }
163170 } else {
164171 // Upload to S3 without abort capability
165172 await this . s3Client . send ( new PutObjectCommand ( uploadParams ) ) ;
You can’t perform that action at this time.
0 commit comments