-
-
Notifications
You must be signed in to change notification settings - Fork 775
fix(issue): auto startup never invokes stale_crash_lock auto-fix despite fixable:true marker #6244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jeremymcs
merged 3 commits into
main
from
issue/5666-auto-startup-never-invokes-stale-crash-l-1778944509
May 16, 2026
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/resources/extensions/gsd/tests/auto-remote-session-lock-cleanup.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import test from "node:test"; | ||
| import assert from "node:assert/strict"; | ||
| import { mkdtempSync, mkdirSync, rmSync } from "node:fs"; | ||
| import { join } from "node:path"; | ||
| import { tmpdir } from "node:os"; | ||
|
|
||
| import { checkRemoteAutoSession } from "../auto.ts"; | ||
| import { openDatabase, closeDatabase, _getAdapter } from "../gsd-db.ts"; | ||
| import { registerAutoWorker } from "../db/auto-workers.ts"; | ||
| import { normalizeRealPath } from "../paths.ts"; | ||
| import { readCrashLock } from "../crash-recovery.ts"; | ||
|
|
||
| function makeBase(): string { | ||
| const base = mkdtempSync(join(tmpdir(), "gsd-remote-lock-cleanup-")); | ||
| mkdirSync(join(base, ".gsd"), { recursive: true }); | ||
| return base; | ||
| } | ||
|
|
||
| function cleanup(base: string): void { | ||
| try { closeDatabase(); } catch {} | ||
| try { rmSync(base, { recursive: true, force: true }); } catch {} | ||
| } | ||
|
|
||
| function expireWorker(workerId: string): void { | ||
| const db = _getAdapter()!; | ||
| db.prepare( | ||
| `UPDATE workers SET last_heartbeat_at = '1970-01-01T00:00:00.000Z' WHERE worker_id = :worker_id`, | ||
| ).run({ ":worker_id": workerId }); | ||
| } | ||
|
|
||
| function setWorkerPid(workerId: string, pid: number): void { | ||
| const db = _getAdapter()!; | ||
| db.prepare( | ||
| `UPDATE workers SET pid = :pid WHERE worker_id = :worker_id`, | ||
| ).run({ ":pid": pid, ":worker_id": workerId }); | ||
| } | ||
|
|
||
| test("checkRemoteAutoSession clears stale lock state when lock PID is dead", (t) => { | ||
| const base = makeBase(); | ||
| t.after(() => cleanup(base)); | ||
|
|
||
| openDatabase(join(base, ".gsd", "gsd.db")); | ||
| const workerId = registerAutoWorker({ projectRootRealpath: normalizeRealPath(base) }); | ||
| setWorkerPid(workerId, 99999); | ||
| expireWorker(workerId); | ||
|
|
||
| assert.ok(readCrashLock(base), "precondition: stale lock exists before remote session check"); | ||
|
|
||
| const remote = checkRemoteAutoSession(base); | ||
| assert.deepEqual(remote, { running: false }); | ||
| assert.equal(readCrashLock(base), null, "stale lock should be cleared by remote session check"); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.