mirror of
https://github.com/oven-sh/bun
synced 2026-02-15 13:22:07 +00:00
Fix spurious rejected promise handler calls
This commit is contained in:
@@ -1431,10 +1431,28 @@ JSC__JSPromise* JSC__JSPromise__resolvedPromise(JSC__JSGlobalObject* arg0, JSC__
|
||||
return promise;
|
||||
}
|
||||
|
||||
JSC__JSValue JSC__JSPromise__result(const JSC__JSPromise* arg0, JSC__VM* arg1)
|
||||
JSC__JSValue JSC__JSPromise__result(JSC__JSPromise* promise, JSC__VM* arg1)
|
||||
{
|
||||
return JSC::JSValue::encode(arg0->result(reinterpret_cast<JSC::VM&>(arg1)));
|
||||
auto& vm = *arg1;
|
||||
|
||||
// if the promise is rejected we automatically mark it as handled so it
|
||||
// doesn't end up in the promise rejection tracker
|
||||
switch (promise->status(vm)) {
|
||||
case JSC::JSPromise::Status::Rejected: {
|
||||
uint32_t flags = promise->internalField(JSC::JSPromise::Field::Flags).get().asUInt32();
|
||||
if (!(flags & JSC::JSPromise::isFirstResolvingFunctionCalledFlag)) {
|
||||
promise->internalField(JSC::JSPromise::Field::Flags).set(vm, promise, jsNumber(flags | JSC::JSPromise::isHandledFlag));
|
||||
}
|
||||
}
|
||||
// fallthrough intended
|
||||
case JSC::JSPromise::Status::Fulfilled: {
|
||||
return JSValue::encode(promise->result(vm));
|
||||
}
|
||||
default:
|
||||
return JSValue::encode(JSValue {});
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t JSC__JSPromise__status(const JSC__JSPromise* arg0, JSC__VM* arg1)
|
||||
{
|
||||
switch (arg0->status(reinterpret_cast<JSC::VM&>(arg1))) {
|
||||
|
||||
@@ -1519,7 +1519,7 @@ pub const JSPromise = extern struct {
|
||||
pub fn status(this: *const JSPromise, vm: *VM) Status {
|
||||
return shim.cppFn("status", .{ this, vm });
|
||||
}
|
||||
pub fn result(this: *const JSPromise, vm: *VM) JSValue {
|
||||
pub fn result(this: *JSPromise, vm: *VM) JSValue {
|
||||
return cppFn("result", .{ this, vm });
|
||||
}
|
||||
pub fn isHandled(this: *const JSPromise, vm: *VM) bool {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//-- AUTOGENERATED FILE -- 1667784809
|
||||
//-- AUTOGENERATED FILE -- 1668983536
|
||||
// clang-format off
|
||||
#pragma once
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// clang-format off
|
||||
//-- AUTOGENERATED FILE -- 1668835252
|
||||
//-- AUTOGENERATED FILE -- 1668983536
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
@@ -349,7 +349,7 @@ CPP_DECL void JSC__JSPromise__rejectWithCaughtException(JSC__JSPromise* arg0, JS
|
||||
CPP_DECL void JSC__JSPromise__resolve(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2);
|
||||
CPP_DECL JSC__JSPromise* JSC__JSPromise__resolvedPromise(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1);
|
||||
CPP_DECL JSC__JSValue JSC__JSPromise__resolvedPromiseValue(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1);
|
||||
CPP_DECL JSC__JSValue JSC__JSPromise__result(const JSC__JSPromise* arg0, JSC__VM* arg1);
|
||||
CPP_DECL JSC__JSValue JSC__JSPromise__result(JSC__JSPromise* arg0, JSC__VM* arg1);
|
||||
CPP_DECL uint32_t JSC__JSPromise__status(const JSC__JSPromise* arg0, JSC__VM* arg1);
|
||||
|
||||
#pragma mark - JSC::JSInternalPromise
|
||||
|
||||
@@ -167,7 +167,7 @@ pub extern fn JSC__JSPromise__rejectWithCaughtException(arg0: [*c]JSC__JSPromise
|
||||
pub extern fn JSC__JSPromise__resolve(arg0: [*c]JSC__JSPromise, arg1: ?*JSC__JSGlobalObject, JSValue2: JSC__JSValue) void;
|
||||
pub extern fn JSC__JSPromise__resolvedPromise(arg0: ?*JSC__JSGlobalObject, JSValue1: JSC__JSValue) [*c]JSC__JSPromise;
|
||||
pub extern fn JSC__JSPromise__resolvedPromiseValue(arg0: ?*JSC__JSGlobalObject, JSValue1: JSC__JSValue) JSC__JSValue;
|
||||
pub extern fn JSC__JSPromise__result(arg0: [*c]const JSC__JSPromise, arg1: [*c]JSC__VM) JSC__JSValue;
|
||||
pub extern fn JSC__JSPromise__result(arg0: [*c]JSC__JSPromise, arg1: [*c]JSC__VM) JSC__JSValue;
|
||||
pub extern fn JSC__JSPromise__status(arg0: [*c]const JSC__JSPromise, arg1: [*c]JSC__VM) u32;
|
||||
pub extern fn JSC__JSInternalPromise__create(arg0: ?*JSC__JSGlobalObject) [*c]JSC__JSInternalPromise;
|
||||
pub extern fn JSC__JSInternalPromise__isHandled(arg0: [*c]const JSC__JSInternalPromise, arg1: [*c]JSC__VM) bool;
|
||||
|
||||
Reference in New Issue
Block a user