fix(windows): retain failed native inspection ownership (#1826)

This commit is contained in:
Ysopwnable
2026-10-11 21:33:25 +08:00
committed by GitHub
parent 6ac5c36503
commit 0b4ce83618
11 changed files with 240 additions and 19 deletions
+8 -4
View File
@@ -412,13 +412,17 @@ napi_value processCall(napi_env env, const std::wstring& operation, const std::v
throw Failure("Unknown native process operation", L"", ERROR_INVALID_PARAMETER);
}
napi_value inspect(napi_env env) {
napi_value inspect(napi_env env, std::unique_ptr<Runtime>& probe) {
// Settle the previous owner before admitting another probe. Failed cleanup
// retains its handles, including when identity construction itself failed.
if (probe) { closeRuntime(*probe); probe.reset(); }
wchar_t temp[32768];
const auto length = GetTempPathW(32768, temp);
require(length > 0 && length < 32768, "Read temporary directory coordinate failed");
auto root = createRuntime(std::wstring(temp, length), L"rea-native-probe-");
auto filesystem = identity(env, root->directory.get(), root->path);
closeRuntime(*root);
probe = createRuntime(std::wstring(temp, length), L"rea-native-probe-");
auto filesystem = identity(env, probe->directory.get(), probe->path);
closeRuntime(*probe);
probe.reset();
auto job = createJob();
Attributes attributes(1);
HANDLE raw = job.get();