diff --git a/native/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.cpp b/native/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.cpp index 50c9544896..c7189eb8b7 100644 --- a/native/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.cpp +++ b/native/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.cpp @@ -397,8 +397,6 @@ JS_BINDED_CONSTRUCTOR_IMPL(MinXmlHttpRequest) JS::RootedObject proto(cx, MinXmlHttpRequest::js_proto); JS::RootedObject obj(cx, JS_NewObjectWithGivenProto(cx, MinXmlHttpRequest::js_class, proto)); - js_add_FinalizeHook(cx, obj, false); - jsb_new_proxy(cx, req, obj); #if CC_ENABLE_GC_FOR_NATIVE_OBJECTS js_add_FinalizeHook(cx, obj, true); @@ -411,6 +409,7 @@ JS_BINDED_CONSTRUCTOR_IMPL(MinXmlHttpRequest) req->autorelease(); // JS::AddNamedObjectRoot(cx, &p->obj, "XMLHttpRequest"); #endif + jsb_new_proxy(cx, req, obj); JS::RootedValue out(cx); if (obj) diff --git a/native/cocos/scripting/js-bindings/manual/network/jsb_websocket.cpp b/native/cocos/scripting/js-bindings/manual/network/jsb_websocket.cpp index 0f47a7b343..a07f7561af 100644 --- a/native/cocos/scripting/js-bindings/manual/network/jsb_websocket.cpp +++ b/native/cocos/scripting/js-bindings/manual/network/jsb_websocket.cpp @@ -175,6 +175,7 @@ public: auto copy = &p->obj; JS::RemoveObjectRoot(cx, copy); #endif + JS_SetPrivate(p->obj, nullptr); jsb_remove_proxy(p); } }