Show actionable error when Slack locks cookie database#32
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Previously copyFileSync failures were silently swallowed, returning an empty cookie string that led to confusing 'invalid token' errors. Now EBUSY is detected and throws with a message telling the user to quit the Slack app. Co-authored-by: JaeKyu Jin <iowm0818@naver.com>
ensureSlackAuth previously swallowed all extraction errors silently. Now EBUSY / cookie-lock errors propagate so the user sees the actionable message on any command, not just 'auth extract'. Co-authored-by: JaeKyu Jin <iowm0818@naver.com>
aa28192 to
f0f51e3
Compare
There was a problem hiding this comment.
2 issues found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/platforms/slack/token-extractor.test.ts">
<violation number="1" location="src/platforms/slack/token-extractor.test.ts:156">
P2: Restore the `copyFileSync` spy in a `finally` block to avoid leaking a global fs mock when the assertion fails.</violation>
</file>
<file name="src/platforms/slack/ensure-auth.ts">
<violation number="1" location="src/platforms/slack/ensure-auth.ts:30">
P2: The new cookie-lock check can throw inside the catch block when `error` is not an `Error` object, which can mask the original exception.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Comment on lines
+156
to
+159
| const extractor = new TokenExtractor('darwin', slackDir) | ||
| await expect(extractor.extract()).rejects.toThrow('Quit the Slack app completely and try again') | ||
|
|
||
| copyFileSyncSpy.mockRestore() |
There was a problem hiding this comment.
P2: Restore the copyFileSync spy in a finally block to avoid leaking a global fs mock when the assertion fails.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/platforms/slack/token-extractor.test.ts, line 156:
<comment>Restore the `copyFileSync` spy in a `finally` block to avoid leaking a global fs mock when the assertion fails.</comment>
<file context>
@@ -133,6 +134,31 @@ describe('TokenExtractor Windows DPAPI', () => {
+ })
+
+ // when — then
+ const extractor = new TokenExtractor('darwin', slackDir)
+ await expect(extractor.extract()).rejects.toThrow('Quit the Slack app completely and try again')
+
</file context>
Suggested change
| const extractor = new TokenExtractor('darwin', slackDir) | |
| await expect(extractor.extract()).rejects.toThrow('Quit the Slack app completely and try again') | |
| copyFileSyncSpy.mockRestore() | |
| try { | |
| const extractor = new TokenExtractor('darwin', slackDir) | |
| await expect(extractor.extract()).rejects.toThrow('Quit the Slack app completely and try again') | |
| } finally { | |
| copyFileSyncSpy.mockRestore() | |
| } |
| } | ||
| } catch {} | ||
| } catch (error) { | ||
| if ((error as NodeJS.ErrnoException).code === 'EBUSY' || (error as Error).message.includes('locking the cookie')) { |
There was a problem hiding this comment.
P2: The new cookie-lock check can throw inside the catch block when error is not an Error object, which can mask the original exception.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/platforms/slack/ensure-auth.ts, line 30:
<comment>The new cookie-lock check can throw inside the catch block when `error` is not an `Error` object, which can mask the original exception.</comment>
<file context>
@@ -26,5 +26,10 @@ export async function ensureSlackAuth(): Promise<void> {
}
- } catch {}
+ } catch (error) {
+ if ((error as NodeJS.ErrnoException).code === 'EBUSY' || (error as Error).message.includes('locking the cookie')) {
+ throw error
+ }
</file context>
Suggested change
| if ((error as NodeJS.ErrnoException).code === 'EBUSY' || (error as Error).message.includes('locking the cookie')) { | |
| const code = typeof error === 'object' && error !== null ? (error as NodeJS.ErrnoException).code : undefined | |
| const message = error instanceof Error ? error.message : String(error) | |
| if (code === 'EBUSY' || message.includes('locking the cookie')) { |
devxoul
added a commit
that referenced
this pull request
Mar 5, 2026
Fix spy leak and unsafe error cast from PR #32 review
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
When the Slack desktop app is running, it holds an EBUSY lock on the Cookies SQLite file.
copyFileSyncfails silently, returning an empty cookie — leading to confusing "No workspace configured" or "Extracted tokens are invalid" errors with no hint about the actual cause. Now the EBUSY error is detected and surfaces a clear message telling the user to quit Slack and retry.Changes
token-extractor.tsEBUSYfromcopyFileSyncinreadCookieFromDB()and throw with a descriptive message instead of silently returning''.ensure-auth.tsBefore
After
Verification
bun typecheck— clean.bun test— 852 pass, 0 fail.Summary by cubic
Shows a clear, actionable error when the Slack app locks the cookies database (EBUSY), telling users to quit Slack and try again. Prevents silent failures that caused “No workspace configured” or “invalid token” messages.
Written for commit f0f51e3. Summary will update on new commits.