fix(desktop): preflight a WSL server dependency so a missing-deps regression fails safe
The WSL preflight only validated node-pty, so when the server's externalized node_modules wasn't readable by WSL's Node (the ERR_MODULE_NOT_FOUND bug), preflight passed and wsl-only mode failed to launch with no Windows fallback. Add a server-dependency canary to the probe: resolve "effect" (the framework every server module imports) from the server directory, which validates the whole node_modules tree is present on the WSL filesystem. On failure (exit 3, kept distinct from a node-pty problem) report a fatal preflight failure, so wsl-only mode falls back to Windows and dual mode surfaces the reason inline, instead of the server crash-looping on ERR_MODULE_NOT_FOUND once it launches.
This commit is contained in:
1 parent
bbb7ba7b07
commit
ad2a0959c3
1 file changed
+22
@@ -158,6 +158,15 @@ const NODE_PTY_PROBE_SCRIPT = (
|
||||
linuxServerDir: string,
|
||||
) => `echo "nodePath:$(command -v node 2>/dev/null)"
|
||||
cd ${shellQuote(linuxServerDir)} && node <<'NODE' >/dev/null 2>&1
|
||||
// The server bundle externalizes its deps to node_modules, and the WSL Node
|
||||
// can't read inside app.asar, so confirm those deps are unpacked on the real
|
||||
// filesystem before reporting the backend healthy. "effect" is the framework
|
||||
// every server module imports; resolving it validates the whole node_modules
|
||||
// tree. Exit 3 marks this distinct from a node-pty problem so the caller can
|
||||
// report it accurately instead of letting the server crash on
|
||||
// ERR_MODULE_NOT_FOUND at launch (which, in wsl-only mode, would just fail to
|
||||
// launch with no fallback).
|
||||
try { require.resolve("effect"); } catch (_e) { process.exit(3); }
|
||||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
const pkgDir = path.dirname(require.resolve("node-pty/package.json"));
|
||||
@@ -328,6 +337,19 @@ const ensureNodePtyImpl = (
|
||||
return { ok: false, reason } as const;
|
||||
}
|
||||
|
||||
// Server dependencies (e.g. "effect") couldn't be resolved on the WSL
|
||||
// filesystem — a packaging regression, since the server bundle needs its
|
||||
// node_modules unpacked from the asar. Fatal so wsl-only mode falls back to
|
||||
// Windows and dual mode surfaces the reason inline, instead of the server
|
||||
// crash-looping on ERR_MODULE_NOT_FOUND once it actually launches.
|
||||
if (probe.exitCode === 3) {
|
||||
return {
|
||||
ok: false,
|
||||
reason:
|
||||
'WSL server dependencies could not be loaded (for example "effect"). The server\'s bundled node_modules is not readable by the WSL distro\'s Node — this is a packaging problem with this build. Please report it.',
|
||||
} as const;
|
||||
}
|
||||
|
||||
if (probe.exitCode === 0) return { ok: true, nodePath } as const;
|
||||
|
||||
// node is present but node-pty's native module didn't load.
|
||||
|
||||
Reference in new issue
Block a user