bun icon indicating copy to clipboard operation
bun copied to clipboard

Raise error on unhandled rejected promises

Open zhuzilin opened this issue 3 years ago • 2 comments

fix #970, #953

This is a simpler version of RejectedPromiseTracker in WebKit, which will save the unhandled promises in a vector.

Thank you for your time on this PR :)

zhuzilin avatar Aug 07 '22 04:08 zhuzilin

JSPromise is GC'd, so we cannot safely hold a reference to pending promises this way in an array without using JSC::Weak, JSC::Strong, gcProtect() or keeping a reference on the stack.

Maybe, instead, we could print the first promise and then have a hash table which hashes the pointers? We could clear this hash table at the end of the next tick

Jarred-Sumner avatar Aug 07 '22 16:08 Jarred-Sumner

@Jarred-Sumner

JSPromise is GC'd, so we cannot safely hold a reference to pending promises this way in an array without using JSC::Weak, JSC::Strong, gcProtect() or keeping a reference on the stack.

oh... I thought comparing JSPromise (promise_a.asValue() == promise_b.asValue()) was comparing their actual values instead of the pointer...

Maybe, instead, we could print the first promise and then have a hash table which hashes the pointers? We could clear this hash table at the end of the next tick

Is there a way to get the content of the promise, because I think that the pointer may change between gc. When I print a promise, I can see the .bytes in it, it that the value of the internal field and can we use that?

zhuzilin avatar Aug 07 '22 16:08 zhuzilin