@@ -161,21 +161,24 @@ async function createUploadRequest(
161
161
'Content-Type' : `multipart/form-data; boundary=${ boundary } `
162
162
}
163
163
} )
164
- // Send the request body (headers + files).
165
- for ( const part of requestBody ) {
166
- if ( typeof part === 'string' ) {
167
- req . write ( part )
168
- } else {
169
- part . pipe ( req , { end : false } )
170
- // Wait for file streaming to complete.
171
- // eslint-disable-next-line no-await-in-loop
172
- await events . once ( part , 'end' )
173
- // Ensure a new line after file content.
174
- req . write ( '\n' )
164
+ try {
165
+ // Send the request body (headers + files).
166
+ for ( const part of requestBody ) {
167
+ if ( typeof part === 'string' ) {
168
+ req . write ( part )
169
+ } else {
170
+ part . pipe ( req , { end : false } )
171
+ // Wait for file streaming to complete.
172
+ // eslint-disable-next-line no-await-in-loop
173
+ await events . once ( part , 'end' )
174
+ // Ensure a new line after file content.
175
+ req . write ( '\n' )
176
+ }
175
177
}
178
+ } finally {
179
+ // Close request after writing all data.
180
+ req . end ( )
176
181
}
177
- // Close request after writing all data.
178
- req . end ( )
179
182
return await getResponse ( req )
180
183
}
181
184
@@ -647,13 +650,15 @@ export class SocketSdk {
647
650
file ?: string
648
651
) : Promise < SocketSdkResultType < 'getOrgFullScan' > > {
649
652
try {
650
- const req = https . request (
651
- `${ this . #baseUrl} orgs/${ encodeURIComponent ( orgSlug ) } /full-scans/${ encodeURIComponent ( fullScanId ) } ` ,
652
- {
653
- method : 'GET' ,
654
- ...this . #reqOptions
655
- }
656
- )
653
+ const req = https
654
+ . request (
655
+ `${ this . #baseUrl} orgs/${ encodeURIComponent ( orgSlug ) } /full-scans/${ encodeURIComponent ( fullScanId ) } ` ,
656
+ {
657
+ method : 'GET' ,
658
+ ...this . #reqOptions
659
+ }
660
+ )
661
+ . end ( )
657
662
const res = await getResponse ( req )
658
663
if ( file ) {
659
664
res . pipe ( createWriteStream ( file ) )
0 commit comments