CodyC
Reliable pattern for cleaning up resources as process exists?
I'm using Explicit Resource Management (I'm familiar with (never mind, unload doesn't fire during SIGINT)
I also know about
await using resource = ...
), but [Symbol.asyncDispose]
doesn't get called if my program is killed with SIGINT or other signals. Is there a known/good pattern for making sure some resource gets cleaned up, even if the process is dying?
window.onunload
, but since that's a global, it feels unreliable to rely on, since anything else in my dependencies might overwrite it during a lengthy runtime. I may also have more than one thing that I want to clean up.Deno.addSignalListener()
but there are an awful lot of signals I'd need to listen to.5 replies
How to open a file as blob?
Docs for Blob (https://deno.land/api@v1.42.0?s=Blob) say that
File
implements Blob
. But the docs for Deno.File (https://deno.land/api@v1.42.0?s=Deno.File) say that it's deprecated and you should use FsFile instead. But FsFile (https://deno.land/api@v1.42.0?s=Deno.FsFile) doesn't implement Blob.
I could probably write my own wrapper that will make FsFile conform to Blob, but that feels like something that might already be in std somewhere?
(update: the important part here is that I want to wrap a file-like object, not read the entire file's contents into memory, since I'm working with potentially large files.)20 replies
Help debugging command that doesn't exit.
Is there a way to have Deno tell me what async tasks are still pending when a program ends?
I'm using a third-party API, and AFAICT
await
ing all the promises I can, but I still get to the end of my main()
and deno
doesn't exit.
So I've got:
Which gives me:
Any suggestions? I guess I'll fire up a debugger...4 replies