mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 11:29:02 +00:00
### What does this PR do? Previously, `JSC__JSPromise__wrap` would call `JSC::JSPromise::resolvedPromise(globalObject, result)` without checking if an exception was thrown during promise resolution. This could happen in certain edge cases, such as when the result value is a thenable that triggers stack overflow, or when the promise resolution mechanism itself encounters an error. When such exceptions occurred, they would escape back to the Zig code, causing the CatchScope assertion to fail with "ASSERTION FAILED: Unexpected exception observed on thread" instead of being properly handled. This PR adds an exception check immediately after calling `JSC::JSPromise::resolvedPromise()` and before the `RELEASE_AND_RETURN` macro. If an exception is detected, the function now clears it and returns a rejected promise with the exception value, ensuring consistent error handling behavior. This matches the pattern already used earlier in the function for the initial function call exception handling. ### How did you verify your code works? new and existing tests --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>