RFC: dropping Bluebird
Would you be open to dropping Bluebird in favor of native promises? I would be happy to write the PR to do this. It would be a breaking change.
This would be nice since I think I've run into an issue due to this. I have code like so:
const data = csv().fromFile('my-data.csv'))
async function doSomeStuff (name) {
await data
return data.find(d => d.name === name)
}
The await hangs. It also hangs if I try data.then(). IIRC this works fine with the standard promise implementation.
@MatthewHerbst Yes. for longer term, native promise is preferred. However csvtojson only uses bluebird internally -- I think no API that returns a Promise object. Could you please let me know what is the reason to replace bluebird?
@evanshortiss Oh.. That is a bug! csv() returns a Thennable object. It does not actually return Bluebird or native promise. However, it has optimisation to check if final result needs to be built. That is if .then or .subscribe or .on('data') or await is not called before first result, it will not build final result to save memory. Would you please shoot a bug on this?
Thanks. Keyang
@Keyang thanks for replying. Two reasons. The first is to reduce dependency bloat: no reason to ship Bluebird to clients when clients already know about Promises. The second is for consistency to reduce bugs, as @evanshortiss noticed. For example, I see in my webpack builds hundreds of lines of:
Warning: .then() only accepts functions but was passed: [object Object]
That comes from some library (not necessarily this one) passing the wrong thing to a Bluebird promise.
Agree! Maybe we should look at dropping bluebird support. Avoids dependency bloat as well :). It would be a breaking change.
This would be nice since I think I've run into an issue due to this. I have code like so:
const data = csv().fromFile('my-data.csv')) async function doSomeStuff (name) { await data return data.find(d => d.name === name) }The
awaithangs. It also hangs if I trydata.then(). IIRC this works fine with the standard promise implementation.
Was so glad to see you mention this and I'm not alone, this just killed my morning :D