From e64fe740147ab075a642eb6e9f89418eb30a0a4b Mon Sep 17 00:00:00 2001 From: Abdul Wasay Date: Tue, 25 Aug 2026 00:11:28 +0500 Subject: [PATCH] fix(runtime): propagate unexpected errno from realpathSync The segment-resolution loop handled ELOOP, ENOENT and ENOTDIR and broke out of the loop on every other errno, returning the partially resolved prefix as if it were the resolved path. A caller hitting EACCES on a path component got the parent directory back instead of an error. Unexpected errnos now go through throwNormalizedFsBridgeError so the guest sees the real failure, and the ENOENT branch uses createFsError so it carries errno like every other fs error from this bridge. --- packages/build-tools/bridge-src/builtins/fs.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/build-tools/bridge-src/builtins/fs.ts b/packages/build-tools/bridge-src/builtins/fs.ts index e92133f795..0080042534 100644 --- a/packages/build-tools/bridge-src/builtins/fs.ts +++ b/packages/build-tools/bridge-src/builtins/fs.ts @@ -4032,13 +4032,11 @@ var fs = { const err = e; if (err.code === "ELOOP") throw e; if (err.code === "ENOENT" || err.code === "ENOTDIR") { - const enoent = new Error(`ENOENT: no such file or directory, realpath '${raw}'`); - enoent.code = "ENOENT"; - enoent.syscall = "realpath"; - enoent.path = raw; - throw enoent; + throw createFsError("ENOENT", `ENOENT: no such file or directory, realpath '${raw}'`, "realpath", raw); } - break; + // Any other errno must reach the caller: returning here handed back the + // partially resolved prefix as if it were the real path. + throwNormalizedFsBridgeError(err, "realpath", raw); } } return "/" + resolved.join("/") || "/";