-
Notifications
You must be signed in to change notification settings - Fork 9
fix: add 3s timeout to keychain init to prevent hang on Linux SSH sessions #16
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,6 +58,17 @@ export class SecureCredentialStore { | |
| */ | ||
| private async initializeKeychain(): Promise<void> { | ||
| try { | ||
| // On Linux without a display session, libsecret's D-Bus call to the Secret | ||
| // Service blocks the Node.js event loop indefinitely — the keyring daemon is | ||
| // running but locked, and the GUI unlock dialog never appears in SSH/headless | ||
| // environments. Since @napi-rs/keyring uses native N-API (not async I/O), | ||
| // Promise.race cannot interrupt it. Bail out early instead. | ||
| if (process.platform === 'linux' && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY) { | ||
| this.keychainAvailable = false; | ||
| logger.debug('Skipping OS keychain: Linux without display (headless/SSH) — using encrypted file storage'); | ||
| return; | ||
|
Comment on lines
+66
to
+69
|
||
| } | ||
|
|
||
| // Dynamically import keyring | ||
| const keyring = await import('@napi-rs/keyring'); | ||
| this.Entry = keyring.Entry; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR title/description say a 3s timeout is added around the keychain test (and mention a "Keychain test timed out after 3000ms" debug message), but the implementation here instead unconditionally skips keychain initialization on Linux when DISPLAY/WAYLAND_DISPLAY are unset and does not implement any timeout. Either update the PR metadata/log expectations to match this behavior, or implement the promised timeout via a cancelable mechanism (e.g., run the keyring test in a worker/child process that can be terminated).