WebAssembly / js-promise-integration

JavaScript Promise Integration
Other
68 stars 17 forks source link

What happens if promises are unresolved #45

Closed yurydelendik closed 2 weeks ago

yurydelendik commented 1 month ago

Here is an example with suspending promise that will be never resolved, also promising one is lost:

{
  const suspending = new WebAssembly.Suspending(() => new Promise(() => {}));
  const ins = wasmEvalText(`(module
    (import "" "s" (func $imp))
    (func (export "f")
      call $imp
    )
  )`, {"": {s: suspending,}});
  const promising = WebAssembly.promising(ins.exports.f);
  promising();
}

Is it correct:

  1. All objects and resources created in this block will be eventually garbage collected.
  2. There will be no any error/exception handling on the suspended stack in result of defunct promise (also when promising() promise still has reference)
  3. No any observable effect in user agents, e.g. console message.
fgmccabe commented 1 month ago

That is correct. No difference in principle to creating any garbage.