Open adrianbrowning opened 9 months ago
Try moving this to the bottom of the file and prepending await
:
await clearDB()
.then(run)
.catch(e => console.error(e))
.then(closeDb)
.then(_=>{
console.log(`Ended: ${new Date}, took ${humanizeDuration(performance.now() - start)}`);
return null;
})
.catch(e => {throw e;});
Thanks @Jarred-Sumner , just adding the await
did the trick.
I hadn't thought to do that, as the code works in NodeJS land.
Seems odd that you would need to prepend the await
as it is a valid promise chain, is it not?
what is happening is somewhere in this line of async work, bun does not realize there are active operations happening, so it quits thinking the async work is done.
the await
prevents the main file from finish running before that.
this is still a bug its just not immediatly clear what part of the async chain is forgetting to keep the event loop alive.
@paperdave seems similar to this other issue , where adding an await
caused the program to work as expected.
What version of Bun is running?
1.0.29+a146856d1
What platform is your computer?
Darwin 23.3.0 x86_64 i386
What steps can reproduce the bug?
Here is a small repo that can reproduce the issue. https://github.com/adrianbrowning/mvt-bun-prisma.
bun i
, will also create the db.db filebun no-brk
/bun just-inspect
and see that the output stopbun with-brk
. Brin up the debugger and see that the output continues.What is the expected behavior?
Running
bun with-brk
gives:What do you see instead?
Running
bun no-brk
ORbun just-inspect
both show the following:Additional information
Might also relate to: https://github.com/oven-sh/bun/issues/8629