From 918fe702a958256698b429e6c0f4940b1f5d4aef Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 5 Oct 2026 10:45:39 -0700 Subject: [PATCH] fix(windows): rename files without requesting execute access Use the existing non-executable source-open rights directly and remove the redundant retry. FILE_TRAVERSE aliases FILE_EXECUTE for regular files and can serialize antivirus scans during compile-cache publication. Keep the workload, deadlines, idle-generation policy and signal-exit budget unchanged. Distinguish the resolved Linux accounting issue from Windows publication delays in the CI notes, and include entry counts in the existing stalled-progress diagnostic. --- .github/OPENCLAW_CI.md | 22 ++++++--- CHANGELOG.md | 2 + docs/runtime/nodejs-compat.mdx | 2 +- src/sys/windows/mod.rs | 45 +++++-------------- .../js/node/module/node-module-module.test.js | 4 +- 5 files changed, 34 insertions(+), 41 deletions(-) diff --git a/.github/OPENCLAW_CI.md b/.github/OPENCLAW_CI.md index 43741a63cf84..a757b4114083 100644 --- a/.github/OPENCLAW_CI.md +++ b/.github/OPENCLAW_CI.md @@ -126,8 +126,20 @@ attempts. These are build-step times, excluding provisioning and artifact upload The first test attempt failed `compile cache wakes an idle loop for deferred modules` in `test/js/node/module/node-module-module.test.js` with `idle -persistence stalled`; the unchanged rerun passed every selected file. Keep -this intermittent failure visible: the lane has no automatic test retries or -exclusion for it. Investigate idle persistence separately if it recurs; a -green rerun does not establish the cause. Artifact names include the run -attempt so a download cannot confuse an earlier failed report with a later one. +persistence stalled`. [PR #53](https://github.com/openclaw/bun/pull/53) fixed +that Linux idle-accounting bug: a poll following a consumed native wake could +block without counting its wait as idle. + +Windows x64 [run 37340737589](https://github.com/openclaw/bun/actions/runs/37340737589) +later hit the outer 30-second deadlines in both cache-exit and deferred-idle +tests. The same failure reproduces with continuous cache-file progress under +Microsoft Defender. The Windows rename helper requested `FILE_TRAVERSE`, which +is `FILE_EXECUTE` for a regular file, forcing synchronous executable-file scans +for each cache entry. The helper now uses its existing non-executable access +rights directly. The test workloads, deadlines, idle-generation window, and +signal-exit budget are unchanged. + +Keep later failures distinguishable from these causes; a green rerun does not +establish a cause. The native lane has no automatic test retries or exclusion +for this file. Artifact names include the run attempt so a download cannot +confuse an earlier failed report with a later one. diff --git a/CHANGELOG.md b/CHANGELOG.md index c35d4ef96b58..6ac1f02db1ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -201,3 +201,5 @@ - Support real byte-based `node:inspector` HeapProfiler allocation sampling with allocation-site trees, live profiles, and major/minor GC inclusion flags (requires the OpenClaw WebKit allocation sampler). - Preserve built-in error constructor syntax and returning arrow frames, and use JSC syntax-selected call and property-read stack positions. Retain runtime callee parentheses and computed access, and map call, bracket, and template delimiters back to their original source. Continues the source-position fixes from [oven-sh/bun#35179](https://github.com/oven-sh/bun/pull/35179), [oven-sh/bun#37396](https://github.com/oven-sh/bun/pull/37396), and [oven-sh/bun#41580](https://github.com/oven-sh/bun/pull/41580). Thanks @robobun! - Add position-preserving `module.stripTypeScriptTypes()` strip mode for tooling that analyzes TypeScript exports. Adapts [oven-sh/bun#35517](https://github.com/oven-sh/bun/pull/35517); thanks @cirospaciari! + +- Avoid requesting executable access when renaming files on Windows, preventing unnecessary synchronous antivirus scans during compile-cache publication. diff --git a/docs/runtime/nodejs-compat.mdx b/docs/runtime/nodejs-compat.mdx index 68611635b4dd..006bb7f61c29 100644 --- a/docs/runtime/nodejs-compat.mdx +++ b/docs/runtime/nodejs-compat.mdx @@ -210,7 +210,7 @@ Package imports and exports match the `module-sync` condition for both `import` `NODE_COMPILE_CACHE` and `module.enableCompileCache()` generate and atomically write cache entries during idle time. Normal exits wait for pending cache work. After a native SIGTERM, SIGINT, or SIGHUP, Bun limits automatic exit-time cache waiting to 250 ms, including when JavaScript handled the signal. Unfinished entries compile normally on the next run. Explicit `module.flushCompileCache()` calls always wait for persistence to finish. Standalone executables ignore `NODE_COMPILE_CACHE`. -Deferred cache generation continues on idle event loops even after JavaScript timers are removed. Its native wakeups do not keep the process alive. +Deferred cache generation continues on idle event loops even after JavaScript timers are removed. Its native wakeups do not keep the process alive. Windows cache publication avoids requesting executable access to cache data files, which can otherwise trigger synchronous antivirus scans. ### [`node:net`](https://nodejs.org/api/net.html) diff --git a/src/sys/windows/mod.rs b/src/sys/windows/mod.rs index d2eac80990ea..3df472226996 100644 --- a/src/sys/windows/mod.rs +++ b/src/sys/windows/mod.rs @@ -1895,40 +1895,17 @@ pub(crate) fn rename_at_w( new_path_w: &[u16], replace_if_exists: bool, ) -> bun_sys::Result<()> { - let src_fd = 'brk: { - match bun_sys::open_file_at_windows( - old_dir_fd, - old_path_w, - bun_sys::NtCreateFileOptions { - access_mask: win32::SYNCHRONIZE - | win32::GENERIC_WRITE - | win32::DELETE - | win32::FILE_TRAVERSE, - disposition: win32::FILE_OPEN, - options: win32::FILE_SYNCHRONOUS_IO_NONALERT | win32::FILE_OPEN_REPARSE_POINT, - ..Default::default() - }, - ) { - bun_sys::Result::Err(_) => { - // retry, wtihout FILE_TRAVERSE flag - match bun_sys::open_file_at_windows( - old_dir_fd, - old_path_w, - bun_sys::NtCreateFileOptions { - access_mask: win32::SYNCHRONIZE | win32::GENERIC_WRITE | win32::DELETE, - disposition: win32::FILE_OPEN, - options: win32::FILE_SYNCHRONOUS_IO_NONALERT - | win32::FILE_OPEN_REPARSE_POINT, - ..Default::default() - }, - ) { - bun_sys::Result::Err(err2) => return bun_sys::Result::Err(err2), - bun_sys::Result::Ok(fd) => break 'brk fd, - } - } - bun_sys::Result::Ok(fd) => break 'brk fd, - } - }; + // FILE_TRAVERSE is FILE_EXECUTE for files and can force synchronous antivirus scans. + let src_fd = bun_sys::open_file_at_windows( + old_dir_fd, + old_path_w, + bun_sys::NtCreateFileOptions { + access_mask: win32::SYNCHRONIZE | win32::GENERIC_WRITE | win32::DELETE, + disposition: win32::FILE_OPEN, + options: win32::FILE_SYNCHRONOUS_IO_NONALERT | win32::FILE_OPEN_REPARSE_POINT, + ..Default::default() + }, + )?; let _close = bun_sys::CloseOnDrop::new(src_fd); move_opened_file_at(src_fd, new_dir_fd, new_path_w, replace_if_exists) diff --git a/test/js/node/module/node-module-module.test.js b/test/js/node/module/node-module-module.test.js index 5c941233624e..7d3b0ae1e93e 100644 --- a/test/js/node/module/node-module-module.test.js +++ b/test/js/node/module/node-module-module.test.js @@ -980,7 +980,9 @@ console.log("survived", require("./late.js"));`, previous = current; deadline = Date.now() + 10_000; } - if (Date.now() >= deadline || proc.exitCode !== null) throw new Error("idle persistence stalled"); + if (Date.now() >= deadline || proc.exitCode !== null) { + throw new Error(`idle persistence stalled at ${current}/${minimum} entries (exitCode: ${proc.exitCode})`); + } await Bun.sleep(10); } };