make it not crash by passing thisValue

This commit is contained in:
Zack Radisic
2025-03-31 18:19:23 -07:00
parent 0662640d9f
commit 1485bc71d3
3 changed files with 9 additions and 9 deletions

View File

@@ -166,6 +166,8 @@ export default [
onabort: {
getter: "getOnAbort",
setter: "setOnAbort",
passThis: true,
this: true,
},
hasCustomOnData: {
getter: "getHasCustomOnData",

View File

@@ -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;

View File

@@ -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();