cicy-desktop 2.1.137 → 2.1.138
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/sidecar/wsl-docker.js +26 -5
package/package.json
CHANGED
|
@@ -119,12 +119,26 @@ async function distroInstalled(distro = DISTRO) {
|
|
|
119
119
|
// Raw `wsl --import` of the rootfs as an ISOLATED v2 distro.
|
|
120
120
|
function importTarball(dest, installDir) {
|
|
121
121
|
return new Promise((resolve, reject) => {
|
|
122
|
+
// 240s, NOT 600s: a 444MB import finishes in well under 4min on a healthy WSL.
|
|
123
|
+
// If it runs longer it has WEDGED (the whole WSL subsystem hangs — every later
|
|
124
|
+
// `wsl` call then blocks and the app goes 未响应). Bound it short so we FAIL FAST
|
|
125
|
+
// and the caller can `wsl --shutdown` + retry instead of hanging 10 minutes.
|
|
122
126
|
execFile("wsl", ["--import", DISTRO, installDir, dest, "--version", "2"],
|
|
123
|
-
{ timeout:
|
|
127
|
+
{ timeout: 240000, windowsHide: true },
|
|
124
128
|
(err, _so, se) => { if (err) { err.stderr = String(se || ""); return reject(err); } resolve(); });
|
|
125
129
|
});
|
|
126
130
|
}
|
|
127
131
|
|
|
132
|
+
// `wsl --shutdown`: hard-reset the ENTIRE WSL VM. This is the only reliable cure
|
|
133
|
+
// when WSL wedges (a hung `wsl --import` leaves every subsequent `wsl` call
|
|
134
|
+
// blocking → the app freezes). Unlike `wsl --list/-d` it doesn't query the wedged
|
|
135
|
+
// VM, so it returns even when WSL is stuck. Use it as recovery between retries.
|
|
136
|
+
function wslShutdown() {
|
|
137
|
+
return new Promise((resolve) => {
|
|
138
|
+
execFile("wsl", ["--shutdown"], { timeout: 30000, windowsHide: true }, () => resolve());
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
128
142
|
// `wsl --terminate <distro>`: stop the distro so the NEXT `wsl -d` cold-boots it
|
|
129
143
|
// clean. This is the fix for the「引擎没起来」-on-fresh-install failure: a distro
|
|
130
144
|
// straight out of `wsl --import` is frequently half-initialized / unresponsive,
|
|
@@ -157,10 +171,17 @@ async function installDistro({ emit } = {}) {
|
|
|
157
171
|
try {
|
|
158
172
|
await importTarball(dest, installDir);
|
|
159
173
|
} catch (e) {
|
|
160
|
-
//
|
|
161
|
-
// (
|
|
162
|
-
|
|
163
|
-
|
|
174
|
+
// Import failed or WEDGED (our 4-min timeout fired). Recover hard, then retry once:
|
|
175
|
+
// 1) `wsl --shutdown` — clears a wedged WSL VM (the real cause of the 8-min hang
|
|
176
|
+
// + app freeze). Without this the retry hits the same stuck VM and hangs again.
|
|
177
|
+
// 2) ensure the WSL2 kernel (import also fails when it's missing).
|
|
178
|
+
// 3) unregister any half-registered distro a wedged import left behind, so the
|
|
179
|
+
// retry imports clean.
|
|
180
|
+
log.warn(`[installDistro] import failed/wedged (${e.message}) → wsl --shutdown + retry`);
|
|
181
|
+
emit && emit({ phase: "container", status: "running", message: "导入卡住,重置 WSL(--shutdown)后重试…" });
|
|
182
|
+
try { await wslShutdown(); } catch {}
|
|
183
|
+
try { await ensureWslKernel({ emit }); } catch {}
|
|
184
|
+
try { await new Promise((r) => execFile("wsl", ["--unregister", DISTRO], { timeout: 30000, windowsHide: true }, () => r())); } catch {}
|
|
164
185
|
await importTarball(dest, installDir);
|
|
165
186
|
}
|
|
166
187
|
// 3) Force a clean cold boot. A freshly-imported distro is often wedged, so the
|