@lark-codem/codem-cli 0.1.271-dev.100103746127.0.g5243898 → 0.1.271-dev.100103768032.0.g9c77ba7
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 +7 -7
- package/profile/config-lock.js +44 -7
- package/profile/runtime-logs.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-codem/codem-cli",
|
|
3
|
-
"version": "0.1.271-dev.
|
|
3
|
+
"version": "0.1.271-dev.100103768032.0.g9c77ba7",
|
|
4
4
|
"codemServiceManagementProtocol": 3,
|
|
5
5
|
"codemWorkerRuntimeProtocol": 1,
|
|
6
6
|
"codemProfileProtocol": 1,
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"@lark-codem/lark-cli": "0.1.1"
|
|
36
36
|
},
|
|
37
37
|
"optionalDependencies": {
|
|
38
|
-
"@lark-codem/codem-cli-darwin-arm64": "0.1.271-dev.
|
|
39
|
-
"@lark-codem/codem-cli-darwin-x64": "0.1.271-dev.
|
|
40
|
-
"@lark-codem/codem-cli-linux-arm64": "0.1.271-dev.
|
|
41
|
-
"@lark-codem/codem-cli-linux-x64": "0.1.271-dev.
|
|
42
|
-
"@lark-codem/codem-cli-win32-arm64": "0.1.271-dev.
|
|
43
|
-
"@lark-codem/codem-cli-win32-x64": "0.1.271-dev.
|
|
38
|
+
"@lark-codem/codem-cli-darwin-arm64": "0.1.271-dev.100103768032.0.g9c77ba7",
|
|
39
|
+
"@lark-codem/codem-cli-darwin-x64": "0.1.271-dev.100103768032.0.g9c77ba7",
|
|
40
|
+
"@lark-codem/codem-cli-linux-arm64": "0.1.271-dev.100103768032.0.g9c77ba7",
|
|
41
|
+
"@lark-codem/codem-cli-linux-x64": "0.1.271-dev.100103768032.0.g9c77ba7",
|
|
42
|
+
"@lark-codem/codem-cli-win32-arm64": "0.1.271-dev.100103768032.0.g9c77ba7",
|
|
43
|
+
"@lark-codem/codem-cli-win32-x64": "0.1.271-dev.100103768032.0.g9c77ba7"
|
|
44
44
|
},
|
|
45
45
|
"engines": {
|
|
46
46
|
"node": ">=18"
|
package/profile/config-lock.js
CHANGED
|
@@ -73,6 +73,7 @@ import { debugLog } from "./debug.js";
|
|
|
73
73
|
const DEFAULT_STALE_MS = 10_000;
|
|
74
74
|
const DEFAULT_TIMEOUT_MS = 15_000;
|
|
75
75
|
const DEFAULT_RETRY_MS = 75;
|
|
76
|
+
const RELEASE_EMPTY_READ_DELAYS_MS = [50, 100, 200, 400, 500, 500];
|
|
76
77
|
const REAPER_CHOOSING_PREFIX = "choosing-";
|
|
77
78
|
const REAPER_TICKET_PREFIX = "ticket-";
|
|
78
79
|
const REAPER_TICKET_WIDTH = 16;
|
|
@@ -160,6 +161,48 @@ async function readOwner(filePath) {
|
|
|
160
161
|
}
|
|
161
162
|
}
|
|
162
163
|
|
|
164
|
+
async function releaseOwnedLock(lockFile, token, sleep) {
|
|
165
|
+
let stage = "read";
|
|
166
|
+
let attempts = 0;
|
|
167
|
+
try {
|
|
168
|
+
// s3fs can return an empty body after the lock was written and closed.
|
|
169
|
+
let raw;
|
|
170
|
+
do {
|
|
171
|
+
attempts++;
|
|
172
|
+
raw = await fs.readFile(lockFile, "utf8");
|
|
173
|
+
if (raw.length !== 0) break;
|
|
174
|
+
if (attempts > RELEASE_EMPTY_READ_DELAYS_MS.length) {
|
|
175
|
+
debugLog("config-lock.release_failed", { lockFile, stage, attempts, outcome: "empty_read_exhausted" });
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
await sleep(RELEASE_EMPTY_READ_DELAYS_MS[attempts - 1]);
|
|
179
|
+
} while (true);
|
|
180
|
+
|
|
181
|
+
stage = "parse";
|
|
182
|
+
const owner = JSON.parse(raw);
|
|
183
|
+
if (typeof owner?.token !== "string") {
|
|
184
|
+
debugLog("config-lock.release_failed", { lockFile, stage, attempts, outcome: "invalid_record" });
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (owner.token !== token) {
|
|
188
|
+
debugLog("config-lock.release_failed", { lockFile, stage: "ownership", attempts, outcome: "owner_changed" });
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// A live holder is the only participant that can remove its lock under this protocol.
|
|
193
|
+
stage = "remove";
|
|
194
|
+
await fs.unlink(lockFile);
|
|
195
|
+
} catch (error) {
|
|
196
|
+
if (error?.code === "ENOENT") return;
|
|
197
|
+
debugLog("config-lock.release_failed", {
|
|
198
|
+
lockFile, stage, attempts, outcome: stage === "parse" ? "invalid_record" : "io_error",
|
|
199
|
+
errorCode: error?.code, errorClass: error?.name,
|
|
200
|
+
// JSON.parse errors can echo file contents. Keep only stack frames.
|
|
201
|
+
stack: error?.stack?.split("\n").filter((line) => line.startsWith(" at ")).join("\n")
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
163
206
|
// 机会性清扫残留 tmp(Bug 7384601509):tmp 的生命周期原本只挂在「获取进程走完所有
|
|
164
207
|
// 出口」上——等待窗口内被 SIGINT/SIGTERM/SIGKILL/崩溃/断电终止的进程,其 tmp 因文件名
|
|
165
208
|
// 内嵌 randomUUID 永不复用而永久残留。这里在每次获取时顺带回收同目录的 `<lock>.tmp-*`
|
|
@@ -298,13 +341,7 @@ export async function acquireConfigLock(targetPath, {
|
|
|
298
341
|
return;
|
|
299
342
|
}
|
|
300
343
|
released = true;
|
|
301
|
-
|
|
302
|
-
// 绝不移动或删除别人的锁。存活 holder 的锁只有自己会删(见头注不变量),
|
|
303
|
-
// 所以这里的 read→unlink 无竞态。
|
|
304
|
-
const owner = await readOwner(lockFile);
|
|
305
|
-
if (owner?.token === token) {
|
|
306
|
-
await fs.rm(lockFile, { force: true }).catch(() => {});
|
|
307
|
-
}
|
|
344
|
+
await releaseOwnedLock(lockFile, token, sleep);
|
|
308
345
|
};
|
|
309
346
|
}
|
|
310
347
|
} finally {
|
package/profile/runtime-logs.js
CHANGED
|
@@ -652,7 +652,7 @@ export function recordInteractiveProcessExit({ exitCode, signal }) {
|
|
|
652
652
|
export function recordSelectedRuntimeLog(component, event, fields = {}) {
|
|
653
653
|
try {
|
|
654
654
|
const selectedEvent = event.replace(/^linco\./u, "");
|
|
655
|
-
if (!/^(?:startup\.(?:main|update_check|daemon_service_reconcile|login_gate|login_handoff_to_linco)|oauth\.refresh\.(?:relogin_suspect|persist_failed|persisted)|managed_config\.(?:member_refresh_failed|sandbox_refresh_failed|sandbox_fetch_recovered|sandbox_fetch_exhausted|refreshed|resource_failed)|(?:agent|command)\.(?:start|interactive_start|success|error|spawn_error|resolve_error|exit_drain_timeout|cancelled_before_spawn|artifact_oversize|artifact_missing|artifact_dropped|artifact_route_selected|artifact_image_upload|artifact_file_upload|artifact_local_register)|router\.credentials\.(?:ensured|refresh_failed)|binary\.heal_chmod_failed|project\.(?:inject_error|state)|(?:permission_ask|user_question|plan)\.report_failed|process_tree\.(?:force_kill|force_kill_failed)|artifact\.(?:oversize|missing|dropped)|runtime_post\.daemon\.device_rebind_[a-z_]+)$/u.test(selectedEvent)) return;
|
|
655
|
+
if (!/^(?:startup\.(?:main|update_check|daemon_service_reconcile|login_gate|login_handoff_to_linco)|oauth\.refresh\.(?:relogin_suspect|persist_failed|persisted)|managed_config\.(?:member_refresh_failed|sandbox_refresh_failed|sandbox_fetch_recovered|sandbox_fetch_exhausted|refreshed|resource_failed)|(?:agent|command)\.(?:start|interactive_start|success|error|spawn_error|resolve_error|exit_drain_timeout|cancelled_before_spawn|artifact_oversize|artifact_missing|artifact_dropped|artifact_route_selected|artifact_image_upload|artifact_file_upload|artifact_local_register)|router\.credentials\.(?:ensured|refresh_failed)|config-lock\.release_failed|binary\.heal_chmod_failed|project\.(?:inject_error|state)|(?:permission_ask|user_question|plan)\.report_failed|process_tree\.(?:force_kill|force_kill_failed)|artifact\.(?:oversize|missing|dropped)|runtime_post\.daemon\.device_rebind_[a-z_]+)$/u.test(selectedEvent)) return;
|
|
656
656
|
const expected = optional(() => fields?.errorKind === "user_stop" || fields?.terminalError?.kind === "user_stop" || fields?.exitCode === 130 || fields?.signal === "SIGINT");
|
|
657
657
|
const level = expected ? "info" : (fields?.status === "failed" || /(?:failed|error|exhausted|timeout)$/u.test(event)) ? "error" : /(?:suspect|dropped|missing|oversize)$/u.test(event) ? "warn" : "info";
|
|
658
658
|
recordRuntimeLog(level, component, event, fields);
|