mirror of
https://github.com/morluto/rea.git
synced 2026-12-05 22:41:36 +00:00
fix(process): compare Windows server paths by native realpath (#15044)
* fix(process): compare Windows server paths by native realpath compareServerPaths returned mismatch for every non-equal Windows path, so case, separator, 8.3, and junction spellings of the running server were reported as registration_path_mismatch. Compare native realpaths on Windows, matching registration identity: a different existing file still mismatches and an unresolvable path stays unknown. * test(process): run the server path identity regression on Windows The injected win32 platform only selects the comparison branch; on the Linux source-test host realpathSync.native still uses POSIX rules, so Windows letter case, separators, and junction behavior were unverified. Add Windows-only spelling cases beside the portable regression and include the file in the curated Windows lane, with the lane guard asserting it stays there. * ci(windows): own the server identity regression in the package lane The Windows lane now runs serverIdentity.test.ts, so the package scope must own that path for the native-host lane ownership check. * docs(process): clarify server path comparison authority --------- Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
This commit is contained in:
1 parent
78c6d4c5a8
commit
60de294646
5 files changed
+96
-2
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { statSync } from "node:fs";
|
||||
import { realpathSync, statSync } from "node:fs";
|
||||
import { dirname, basename, resolve } from "node:path";
|
||||
|
||||
import { HOST_PLATFORM } from "../platform/HostPlatform.js";
|
||||
@@ -38,13 +38,22 @@ const compareServerPaths = (
|
||||
expected: string,
|
||||
observed: string,
|
||||
runtime: JavaScriptRuntime["id"],
|
||||
platform: NodeJS.Platform,
|
||||
): "aligned" | "mismatch" | "unknown" => {
|
||||
// Select the registered script the way this runtime does: Node resolves it
|
||||
// lexically, while Bun follows native traversal through a symlink before `..`.
|
||||
const script = normalizeEntrypointPath(expected, runtime) ?? expected;
|
||||
if (script === observed) return "aligned";
|
||||
if (HOST_PLATFORM.platform === "win32") return "mismatch";
|
||||
try {
|
||||
// Windows identity comes from the native realpath, matching registration
|
||||
// identity: case, separators, 8.3 names, and junctions to the same file
|
||||
// canonicalize to one path, while a different file stays a mismatch.
|
||||
// Like the POSIX stat below, this inspects a caller-selected filesystem
|
||||
// path and preserves the shared Windows path contract.
|
||||
if (platform === "win32")
|
||||
return realpathSync.native(script) === realpathSync.native(observed)
|
||||
? "aligned"
|
||||
: "mismatch";
|
||||
const selected = statSync(script, { bigint: true });
|
||||
const running = statSync(observed, { bigint: true });
|
||||
return selected.dev === running.dev && selected.ino === running.ino
|
||||
@@ -65,6 +74,8 @@ export const createServerIdentity = (input: {
|
||||
readonly catalog: ReturnType<typeof createCatalogIdentity>;
|
||||
/** The runtime that selected `commandPath`; defaults to the current one. */
|
||||
readonly runtime?: JavaScriptRuntime["id"];
|
||||
/** The platform whose path identity rules apply; defaults to this host. */
|
||||
readonly platform?: NodeJS.Platform;
|
||||
}) => {
|
||||
const catalog = input.catalog;
|
||||
const serverPath = input.commandPath || undefined;
|
||||
@@ -75,6 +86,7 @@ export const createServerIdentity = (input: {
|
||||
input.expected.server_path,
|
||||
serverPath,
|
||||
input.runtime ?? javaScriptRuntime(process.versions).id,
|
||||
input.platform ?? HOST_PLATFORM.platform,
|
||||
);
|
||||
const reasons: string[] = [];
|
||||
if (
|
||||
|
||||
Reference in new issue
Block a user