finish event never fires
See original GitHub issueI am trying to upload some images to my cloud storage. I am using form data to send the data down to the cloud function. The data arrives correctly, but the Busboy process never finishes processing it and the function timeouts after 60s.
Here is the implementation:
const firebase = require("firebase");
const Busboy = require("busboy");
require("firebase/storage");
const firebase_db = firebase_admin.database();
const firebase_storage = firebase.storage();
module.exports = (req, res) => {
const busboy = new Busboy({headers: req.headers});
const fields = {};
const files = {};
busboy.on('field', (fieldname, val) => {
fields[fieldname] = val;
});
busboy.on('file', (fieldname, file, filename) => {
files[fieldname] = file;
});
busboy.on('finish', async () => { // ----> Function never fires
try {
let project_id = await firebase_db.ref("/project_config/project_id").once("value")
project_id = project_id.val()
if (!project_id) return res.send({ message: "Project ID not found" })
const new_image_storage_ref = firebase_storage.ref().child(`${project_id}/${fields.route}`)
const snapshot = await new_image_storage_ref.put(files.image)
const download_url = await snapshot.ref.getDownloadURL()
res.send(download_url)
} catch (error) {
console.log("----- Error during saving content data ", error)
res.send({ message: "Error during saving your image, please re-load page and try again or contact support." })
}
});
}
Do you have any idea what might be causing it?
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (3 by maintainers)
Top Results From Across the Web
Node.js http response end event never fired - Stack Overflow
Can anyone please tell me why it never fires the end event? How can I make it workable? Code: const http = require('http');...
Read more >File completed event never fires - Deluge Forum
EDIT: Just to clarify, this event is supposed to fire whenever any file in any torrent finishes downloading, right?
Read more >Node.js Readable Stream end Event - GeeksforGeeks
The 'end' Event in a Readable Stream is emitted when there is no available data to be consumed from the readable stream. And...
Read more >Stream | Node.js v19.3.0 Documentation
The 'finish' event is emitted after the stream.end() method has been called, and all data has been flushed to the underlying system.
Read more >map.bounds_changed event fires repeatedly when the map is ...
I'd expect it to fire only when the move has finished. ... If you dont want events during dragging either, can easily combine...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I am having a similar issue. I am trying to write to a path and it does in fact write some of the data, but not all of it and the finish event is never emitted. I’ve tried to add other events to the streams to figure out was is going on but can’t seem to figure it out. This happens when running in a docker container on ECS. It seems to work fine locally.
Node version matters. Works fine with node v14, but in some case with v16, the problem occurs.