mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
make it not crash by passing thisValue
This commit is contained in:
@@ -166,6 +166,8 @@ export default [
|
||||
onabort: {
|
||||
getter: "getOnAbort",
|
||||
setter: "setOnAbort",
|
||||
passThis: true,
|
||||
this: true,
|
||||
},
|
||||
hasCustomOnData: {
|
||||
getter: "getHasCustomOnData",
|
||||
|
||||
@@ -895,22 +895,22 @@ pub fn getOnWritable(this: *NodeHTTPResponse, _: *JSC.JSGlobalObject) JSC.JSValu
|
||||
return this.onWritableCallback.get() orelse .undefined;
|
||||
}
|
||||
|
||||
pub fn getOnAbort(this: *NodeHTTPResponse, _: *JSC.JSGlobalObject) JSC.JSValue {
|
||||
pub fn getOnAbort(this: *NodeHTTPResponse, this_value: JSC.JSValue, _: *JSC.JSGlobalObject) JSC.JSValue {
|
||||
if (this.flags.socket_closed) {
|
||||
return .undefined;
|
||||
}
|
||||
return NodeHTTPResponse.onAbortedGetCached(this.getThisValue()) orelse .undefined;
|
||||
return NodeHTTPResponse.onAbortedGetCached(this_value) orelse .undefined;
|
||||
}
|
||||
|
||||
pub fn setOnAbort(this: *NodeHTTPResponse, globalObject: *JSC.JSGlobalObject, value: JSValue) bool {
|
||||
pub fn setOnAbort(this: *NodeHTTPResponse, this_value: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSValue) bool {
|
||||
if (this.flags.socket_closed) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.isDone() or value == .undefined) {
|
||||
NodeHTTPResponse.onAbortedSetCached(this.getThisValue(), globalObject, .zero);
|
||||
NodeHTTPResponse.onAbortedSetCached(this_value, globalObject, .zero);
|
||||
} else {
|
||||
NodeHTTPResponse.onAbortedSetCached(this.getThisValue(), globalObject, value.withAsyncContextIfNeeded(globalObject));
|
||||
NodeHTTPResponse.onAbortedSetCached(this_value, globalObject, value.withAsyncContextIfNeeded(globalObject));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -974,10 +974,8 @@ extern JSC_CALLCONV void ${symbolName(typeName, name)}SetCachedValue(JSC::Encode
|
||||
|
||||
extern JSC_CALLCONV JSC::EncodedJSValue ${symbolName(typeName, name)}GetCachedValue(JSC::EncodedJSValue thisValue)
|
||||
{
|
||||
auto decoded = JSValue::decode(thisValue);
|
||||
if (decoded.isEmpty()) return JSValue::encode(decoded);
|
||||
auto* thisObject = jsCast<${className(typeName)}*>(decoded);
|
||||
return JSValue::encode(thisObject->${cacheName}.get());
|
||||
auto* thisObject = jsCast<${className(typeName)}*>(JSValue::decode(thisValue));
|
||||
return JSValue::encode(thisObject->${cacheName}.get());
|
||||
}
|
||||
|
||||
`.trim();
|
||||
|
||||
Reference in New Issue
Block a user