Skip to content

Commit 2241541

Browse files
destroy request once done
1 parent ec4374e commit 2241541

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/libraries/Downloader.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ function getFileDownloadURLRedirect(url: string): Promise<string> {
2727
console.log('Headers:', response.headers)
2828
const statusCode = response.statusCode
2929
const location = response.headers.location
30-
let data = ''
31-
response.on('data', d => data += d)
32-
response.on('end', () => console.log('Data:', data))
3330

3431
if (statusCode !== 302) {
3532
request.destroy();
@@ -39,10 +36,12 @@ function getFileDownloadURLRedirect(url: string): Promise<string> {
3936
}
4037

4138
if (typeof location === 'string' && location.length > 0) {
39+
request.destroy()
4240
resolve(location)
4341
return
4442
}
4543

44+
request.destroy()
4645
reject(`Received incorrect URL information. Expected a non-empty string. Received: ${JSON.stringify(location)}`)
4746
})
4847

0 commit comments

Comments
 (0)