atlassian / nucleus

A configurable and versatile update server for all your Electron apps
Other
398 stars 93 forks source link

Socket hang up when uploading to server #90

Open b-zurg opened 4 years ago

b-zurg commented 4 years ago

I've gone down a bit of a rabbit hole trying to figure out why I kept getting a socket timeout error from the electron-forge publisher.

I eventually realized that when I was doing the upload at exactly 2 minutes the upload was failing with this message:

An unhandled error has occurred inside Forge:
request to http://localhost:3030/rest/app/1/channel/eb76a4a94e2a588b9cb9302826aa796f/upload failed, reason: socket hang up
FetchError: request to http://localhost:3030/rest/app/1/channel/eb76a4a94e2a588b9cb9302826aa796f/upload failed, reason: socket hang up
    at ClientRequest.<anonymous> (D:\GitHub\brl-desktop-app\node_modules\node-fetch\dist\index.js:3190:14)
    at ClientRequest.emit (events.js:310:20)
    at ClientRequest.EventEmitter.emit (domain.js:482:12)
    at Socket.socketOnEnd (_http_client.js:453:9)
    at Socket.emit (events.js:322:22)
    at Socket.EventEmitter.emit (domain.js:482:12)
    at endReadableNT (_stream_readable.js:1187:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)

I was simulating a prod server in a local docker compose file but connecting to an actual S3 bucket to test out aspects of the prod infrastructure.

b-zurg commented 4 years ago

Does anyone know why this would be happening?

MarshallOfSound commented 4 years ago

Nucleus itself doesn't have a timeout on the upload. My guess is whatever you are using as an entry point (nginx, apache, etc.) has a connection timeout set to 2 minutes

b-zurg commented 4 years ago

I actually am using the atlassian/nucleus docker image in a docker compose file and connecting directly through the configured port on local host. The rest of the configuration is pointing to S3 and an RDS postgres instance.

Maybe docker is the problem variable here but that would be surprising.

MarshallOfSound commented 4 years ago

Looks like node has a default connection timeout of 2 minutes

https://nodejs.org/dist/latest-v12.x/docs/api/http.html#http_server_settimeout_msecs_callback

b-zurg commented 4 years ago

Oh! Interesting. I'm assuming this has to be done on the server side. I can try it out and make a pull request to either disable the timeout or make it configurable.

b-zurg commented 4 years ago

This was a very helpful find. I managed to configure the server to have a default 30 minute timeout. This worked perfectly. I tested in a similar fashion and was able to release to my s3 bucket without getting a socket hang up.

Would love any feedback :)