question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Finish/End event never fired

See original GitHub issue

I’m trying to setup a Resumable.js NodeJS backend with latest Express (v4). Whatever I upload I never get either the end or finish event.

var busboy = new Busboy({headers: req.headers});
var query = {};
busboy.on('field', function(fieldname, val, fieldnameTruncated, valTruncated) {
  if(fieldname) query[fieldname] = val;
});
busboy.on('file', function(fieldname, file, filename, encoding, mimetype) {
  log.info('Writing chunk-%d/%d of file "%s" from GridFS', query.resumableChunkNumber, query.resumableTotalChunks, query.resumableFilename); // Called
  // var saveTo = path.join(os.tmpDir(), path.basename(fieldname));
  // file.pipe(fs.createWriteStream(saveTo));
});
busboy._parser.parser.on('finish', function() {
  d('Done parsing form!'); // Never called
});
busboy.on('finish', function() {
  d('Done parsing form!'); // Never called
});
busboy.once('end', function() {
  d('Done parsing form!'); // Never called
});
busboy.on('error', function(err) {
  d('err', err);
});
req.pipe(busboy);

Also if I try to res.send(200) on file, somehow it breaks resumable, the behavior is not the same that if I directly res.send(200), even if I have only one file.

Headers

Request URL:http://server-78b0.local:3000/upload
Request Headers
Provisional headers are shown
Accept:application/json, text/plain, */*
Authorization:Bearer eyJ0eTAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6IndhdGNoc2xhdGVAcmljaGVtb250LWNvdWNvdS5jb20iLCJmaXJzdE5hbWUiOiJXYXRjaHNsYXRlIiwibGFzdE5hbWUiOiJBcHBsaWNhdGlvbiIsInBhc3N3b3JkIjoiJDJhJDEwJHJpQXJVMHlQbDZ0MUtwUnFLZ1djbHVVVkxlODdPS2lQbjVTc2VzNzMwS21kTDZYb2JKN2pXIiwiX2lkIjoiNTNjZDFmNTlmMDAxNTIyZDA0MGI1ZWU4IiwiX192IjowfQ.0aQYQNGO2ud7DtjH5ssG_M85i53MakClhBVUQv9AEP0
Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryKAbkqHZYocMBQFF4
Origin:http://localhost:9000
Referer:http://localhost:9000/
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36
Request Payload
------WebKitFormBoundaryKAbkqHZYocMBQFF4
Content-Disposition: form-data; name="resumableChunkNumber"

1
------WebKitFormBoundaryKAbkqHZYocMBQFF4
Content-Disposition: form-data; name="resumableChunkSize"

1048576
------WebKitFormBoundaryKAbkqHZYocMBQFF4
Content-Disposition: form-data; name="resumableCurrentChunkSize"

1048576
------WebKitFormBoundaryKAbkqHZYocMBQFF4
Content-Disposition: form-data; name="resumableTotalSize"

32156861
------WebKitFormBoundaryKAbkqHZYocMBQFF4
Content-Disposition: form-data; name="resumableType"


------WebKitFormBoundaryKAbkqHZYocMBQFF4
Content-Disposition: form-data; name="resumableIdentifier"

32156861-testipa
------WebKitFormBoundaryKAbkqHZYocMBQFF4
Content-Disposition: form-data; name="resumableFilename"

test.ipa
------WebKitFormBoundaryKAbkqHZYocMBQFF4
Content-Disposition: form-data; name="resumableRelativePath"

test.ipa
------WebKitFormBoundaryKAbkqHZYocMBQFF4
Content-Disposition: form-data; name="resumableTotalChunks"

30
------WebKitFormBoundaryKAbkqHZYocMBQFF4
Content-Disposition: form-data; name="file"; filename="blob"
Content-Type: application/octet-stream


------WebKitFormBoundaryKAbkqHZYocMBQFF4--

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
mscdexcommented, Jul 22, 2014

This is flow control doing its duty. For files you need to do something with the file stream, even if it’s just ignoring the data with file.resume();

0reactions
mgcreacommented, Jul 23, 2014

Indeed file.resume() properly fixes it. Now stuck on MongoError: exception: chunks out of order, but that’s another story 😉. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Video event listener waiting for 'ended' not firing - Stack Overflow
You have a loop attribute on the first video. This means it never technically ends, and will just continue playing from the beginning....
Read more >
finish event never fired · Issue #185 · katspaugh/wavesurfer.js
This keeps firing after it has finished playing. See the demo in wavesurfer.fm - see the 'finished playing' duplicates keep going. When I...
Read more >
How to ensure an event listener is only fired once in JavaScript
In this case, the event listener bound to the button to give us permission to view the file should only be fired once...
Read more >
Window: load event - Web APIs - MDN Web Docs - Mozilla
The load event is fired when the whole page has loaded, including all dependent resources such as stylesheets, scripts, iframes, and images.
Read more >
Events | Maps JavaScript API - Google Developers
MVC events, for example, do not pass arguments within their event. ... When a shape is edited or dragged, an event is fired...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found