4 ms·
Javascript does have finalizers now[1], which is a much-needed feature for webassembly interop where you need to explicitly call destructors to clean up any was
by dangerbird2 5y ago
Javascript does have finalizers now[1], which is a much-needed feature for webassembly interop where you need to explicitly call destructors to clean up any wasm data the object owns. However, this wouldn't help with promises where you need cleanup code to be called deterministically, not whenever the GC gets around to cleaning up the object. As you mention, using cancellation tokens that raise an exception is a reasonable solution
[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...