lib: adding keep-alive header to download requests #1863
Closed
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.
Checklist
Description of change
We have been seeing random failures on AIX in the CI when building
node-addon-api
:https://ci.nodejs.org/job/node-test-node-addon-api-new/nodes=aix61-ppc64/481/console
Taking a closer look shows the build fails when gyp is trying to download and extract
node source tarball
. This is done using a stream, data gets decompressed as its being downloaded:I came up with a simpler test case to investigate the cause:
Running the above on AIX using
node test.js
causes the same error to appear. It seemed likethe connection was being interrupted while stream was being decompressed.
I noticed requests are being handled by
cloudflare
. I tried moving theheaders.tar.gz
file to my personal server with https enabled and then ran the script. It worked with no errors.I figured
cloudflare
is most likely dropping the TLS connection once it doesn't hear a tick which happens on AIX as the live tar extraction is interfering with it and is taking longer than other platforms.I looked at the response headers from cloudflare and the default
connection
header is set toclose
. Adding akeep-alive
header in my request managed to fix the problem and force a live connection until the stream is done. I also tested this withnode-addon-api
by modifyinggyp
and the headers were downloaded successfully on AIX.I have found a similar ticket from 2017 whit the same issue which might have been caused by cloudflare dropping connections:
#1084