Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERR_CONNECTION_ABORTED with long file uploads #336

Closed
llaurenss opened this issue Apr 16, 2023 · 6 comments
Closed

ERR_CONNECTION_ABORTED with long file uploads #336

llaurenss opened this issue Apr 16, 2023 · 6 comments

Comments

@llaurenss
Copy link

When im uploading a file after 5-11 minutes the upload will fail and say ERR_CONNECTION_ABORTED im not getting any errors in the Nodejs server. It happens no matter the file size or upload speed. If the file finishes uploading before the 5-11 minute mark everything is fine. I've also tried a different browser but with no success.

I've also recorded a video, I've throttled the network speed to 8mbps so the file upload wouldn't be uploaded instantly because its on localhost. https://youtu.be/uR4AtencXJw

This is my code:

const http = require('http');
const fs = require('fs');

const busboy = require('busboy');

http.createServer((req, res) => {
  if (req.method === 'POST') {
    console.log('POST request');
    const bb = busboy({ headers: req.headers });
    bb.on('file', (name, file, info) => {
      file.pipe(fs.createWriteStream("./upload/test"));
    });

    bb.on('close', () => {
      console.log('Done parsing form!');
      res.writeHead(303, { Connection: 'close', Location: '/' });
      res.end();
    });

    req.pipe(bb);
  } else if (req.method === 'GET') {
    res.writeHead(200, { Connection: 'close' });
    res.end(`
      <html>
        <head></head>
        <body>
          <form method="POST" enctype="multipart/form-data">
            <input type="file" name="filefield"><br />
            <input type="text" name="textfield"><br />
            <input type="submit">
          </form>
        </body>
      </html>
    `);
  }
}).listen(8000, () => {
  console.log('Listening for requests');
});
@mscdex
Copy link
Owner

mscdex commented Apr 16, 2023

Which node.js versions have you tried with?

@mscdex
Copy link
Owner

mscdex commented Apr 16, 2023

Also, what version of busboy are you using?

@llaurenss
Copy link
Author

llaurenss commented Apr 16, 2023

busboy is version 1.6.0
and node.js v18.15.0

edit: I updated node.js to v18.16.0 now but same thing happens

@llaurenss
Copy link
Author

node.js v19.9.0 also same thing happening

@llaurenss
Copy link
Author

llaurenss commented Apr 16, 2023

Found the problem, the http server has a default timeout of 300 seconds which you can change with server.requestTimeout

@mscdex
Copy link
Owner

mscdex commented Apr 17, 2023

FWIW I've now added a note about this in the readme in d08cc9c.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants