node-appwrite 7.0.2 bug: uncaught exception in line 478 of ./lib/services/storage.js
maikeriva opened this issue · 0 comments
maikeriva commented
From discord: https://discord.com/channels/564160730845151244/564161373148414012/999227422648053790
I think I found another bug in the node server SDK (7.0.2)
In line 478 of ./lib/services/storage.js we have:
writeStream.on("finish", async () => {
if(currentChunkSize > 0) {
await uploadChunk(true);
}
resolve(response);
});
That is executed on a createFile
operation. If the given bucket ID is wrong, this section will execute regardless and will throw an error at uploadChunk
. However, since it is thrown within an async function, it cannot get caught by the developer's code flow.
I'd suggest to change it as:
writeStream.on("finish", async () => {
try {
if (currentChunkSize > 0) {
await uploadChunk(true);
}
resolve(response);
} catch (e) {
reject(e)
}
});
This way the exception is propagated and can be handled by developer's code