From bc7f578d955846a15836838c1fd0a44a0792bf78 Mon Sep 17 00:00:00 2001 From: jiang-qunchao Date: Wed, 2 Jul 2025 11:12:24 +0800 Subject: [PATCH] Revert "fix bug" This reverts commit cc3ab44969def5c5614b7b4e4556009c5da1a808. Signed-off-by: jiang-qunchao --- src/js_native_api_v8.cpp | 8 +++++--- src/jsvm_reference.cpp | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/js_native_api_v8.cpp b/src/js_native_api_v8.cpp index db32e36..436ba47 100644 --- a/src/js_native_api_v8.cpp +++ b/src/js_native_api_v8.cpp @@ -1236,14 +1236,14 @@ JSVM_Status OH_JSVM_OpenEnvScope(JSVM_Env env, JSVM_EnvScope* result) { auto *v8scope = env->scopeMemoryManager.New(env->context()); *result = reinterpret_cast(v8scope); - return JSVM_OK; + return ClearLastError(env); } JSVM_Status OH_JSVM_CloseEnvScope(JSVM_Env env, JSVM_EnvScope scope) { auto v8scope = reinterpret_cast(scope); env->scopeMemoryManager.Delete(v8scope); - return JSVM_OK; + return ClearLastError(env); } JSVM_Status OH_JSVM_CompileScript(JSVM_Env env, @@ -1519,7 +1519,7 @@ JSVM_Status OH_JSVM_CreateCodeCache(JSVM_Env env, JSVM_Script script, const uint *length = cache->length; cache->buffer_policy = v8::ScriptCompiler::CachedData::BufferNotOwned; delete cache; - return JSVM_OK; + return ClearLastError(env); } JSVM_Status OH_JSVM_RunScript(JSVM_Env env, JSVM_Script script, JSVM_Value* result) @@ -1689,6 +1689,7 @@ JSVM_EXTERN JSVM_Status OH_JSVM_OpenInspector(JSVM_Env env, const char* host, ui auto agent = env->GetInspectorAgent(); if (!agent->Start(inspectorPath, hostName, port)) { LOG(Error) << "Open Inspector failed: Please check the internet permisson."; + return SetLastError(env, JSVM_GENERIC_FAILURE); } return GET_RETURN_STATUS(env); @@ -4812,6 +4813,7 @@ JSVM_Status OH_JSVM_OpenInspectorWithName(JSVM_Env env, int pid, const char* nam if (!env->GetInspectorAgent()->Start(path, pid)) { LOG(Error) << "Open Inspector failed: Please check the internet permisson."; + return SetLastError(env, JSVM_GENERIC_FAILURE); } return GET_RETURN_STATUS(env); } diff --git a/src/jsvm_reference.cpp b/src/jsvm_reference.cpp index 19d3160..029737c 100644 --- a/src/jsvm_reference.cpp +++ b/src/jsvm_reference.cpp @@ -111,7 +111,7 @@ void FinalizerTracker::CallFinalizer() if (!env) { cbTemp(env, dataTemp, hintTemp); } else { - env->CallFinalizer(cbTemp, dataTemp, hintTemp); + env->CallIntoModule([&](JSVM_Env env) { cbTemp(env, dataTemp, hintTemp); }); } } -- Gitee