Skip to content

Commit b4d990d

Browse files
committed
merge: accept remote fixes for issue #415 (fnSucceeded path)
2 parents 340664c + 515b332 commit b4d990d

2 files changed

Lines changed: 8 additions & 23 deletions

File tree

scripts/verify-ci-test-manifest.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const EXPECTED_BASELINE = [
3939
{ group: "packaging-and-workflow", runner: "node", file: "test/workflow-fork-guards.test.mjs", args: ["--test"] },
4040
{ group: "storage-and-schema", runner: "node", file: "test/clawteam-scope.test.mjs", args: ["--test"] },
4141
{ group: "storage-and-schema", runner: "node", file: "test/cross-process-lock.test.mjs", args: ["--test"] },
42+
{ group: "storage-and-schema", runner: "node", file: "test/lock-stress-test.mjs", args: ["--test"] },
4243
{ group: "core-regression", runner: "node", file: "test/preference-slots.test.mjs", args: ["--test"] },
4344
{ group: "core-regression", runner: "node", file: "test/is-latest-auto-supersede.test.mjs" },
4445
{ group: "core-regression", runner: "node", file: "test/temporal-awareness.test.mjs", args: ["--test"] },

src/store.ts

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@ async function loadLockfile(): Promise<any> {
6464
return lockfileModule;
6565
}
6666

67-
export function __setLockfileModuleForTests(module: any): void {
68-
lockfileModule = module;
69-
}
70-
7167
export const loadLanceDB = async (): Promise<
7268
typeof import("@lancedb/lancedb")
7369
> => {
@@ -218,7 +214,6 @@ export class MemoryStore {
218214
// ECOMPROMISED 透過 onCompromised callback 觸發(非 throw),使用 flag 機制正確處理
219215
let isCompromised = false;
220216
let compromisedErr: any = null;
221-
let fnSucceeded = false;
222217
let fnError: any = null;
223218

224219
const release = await lockfile.lock(lockPath, {
@@ -244,29 +239,18 @@ export class MemoryStore {
244239
});
245240

246241
try {
247-
const result = await fn();
248-
fnSucceeded = true;
249-
return result;
242+
return await fn();
250243
} catch (e: any) {
251-
fnError = e; // 保留 fn() 的錯誤
252-
throw e; // 立刻拋出,讓 caller 知道
244+
fnError = e;
245+
throw e;
253246
} finally {
254247
if (isCompromised) {
255-
// lock 已被 proper-lockfile 標記 released,不需要也無法再次 release
256-
// 若 fn() 已拋錯,fnError 優先(fn() 錯誤不被 lock 錯誤覆蓋)
257-
if (fnError !== null) {
258-
throw fnError;
259-
}
260-
if (!fnSucceeded) {
261-
throw compromisedErr;
248+
if (fnError === null) {
249+
return;
262250
}
263-
console.warn(
264-
`[memory-lancedb-pro] Returning successful result despite compromised lock at "${lockPath}". ` +
265-
`Callers must not retry this operation automatically.`,
266-
);
267-
} else {
268-
await release();
251+
throw fnError;
269252
}
253+
await release();
270254
}
271255
}
272256

0 commit comments

Comments
 (0)