Skip to content

Commit 14e3ba7

Browse files
Myoontyeeclaude
andcommitted
fix: remove sqlite3 CLI fallback — no more subprocess spawning
better-sqlite3 returns [] silently if unavailable (not installed as native module in extension context). sqlite3 CLI fallback is completely removed — it was the root cause of sqlite3.exe pile-up on every poll. Cursor Sessions tab shows 0 if better-sqlite3 not present; safe > broken. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 88bc121 commit 14e3ba7

File tree

3 files changed

+9
-29
lines changed

3 files changed

+9
-29
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "claude-code-exporter",
33
"displayName": "Claude Code Exporter — Claude Code, Codex & Cursor Conversation History",
44
"description": "Export AI coding agent conversations to Markdown. Supports Claude Code (→ .claude-code-history/), OpenAI Codex (→ .codex-history/), and Cursor Composer (→ .cursor-history/). Features: auto-watch, session inject/import for claude --resume, and repair of thinking-block signature errors when switching API providers.",
5-
"version": "0.7.3",
5+
"version": "0.7.4",
66
"publisher": "myoontyee",
77
"engines": {
88
"vscode": "^1.85.0"

src/cursorParser.ts

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
import * as fs from 'fs';
1414
import * as path from 'path';
15-
import * as cp from 'child_process';
1615

1716
// ─── Data model ────────────────────────────────────────────────────────────────
1817

@@ -32,12 +31,14 @@ export interface CursorConversation {
3231
messages: CursorMessage[];
3332
}
3433

35-
// ─── SQLite bridge (via better-sqlite3 or sqlite3 CLI fallback) ────────────────
34+
// ─── SQLite bridge ─────────────────────────────────────────────────────────────
35+
// Uses better-sqlite3 only (must be installed separately as a native module).
36+
// NO subprocess fallback — spawning sqlite3.exe causes process pile-up.
37+
// If better-sqlite3 is unavailable, returns [] silently.
3638

3739
type Row = Record<string, unknown>;
3840

3941
function queryDb(dbPath: string, sql: string, params: (string | number)[] = []): Row[] {
40-
// Primary: try better-sqlite3 (no native issues in recent VS Code versions)
4142
try {
4243
// eslint-disable-next-line @typescript-eslint/no-var-requires
4344
const Database = require('better-sqlite3');
@@ -46,29 +47,8 @@ function queryDb(dbPath: string, sql: string, params: (string | number)[] = []):
4647
const rows = params.length ? stmt.all(...params) : stmt.all();
4748
db.close();
4849
return rows as Row[];
49-
} catch (primaryErr) {
50-
// Fallback: sqlite3 CLI
51-
try {
52-
const escaped = sql.replace(/'/g, "''");
53-
// Substitute params manually (only used for simple string queries here)
54-
let finalSql = sql;
55-
for (const p of params) {
56-
finalSql = finalSql.replace('?', typeof p === 'string' ? `'${p}'` : String(p));
57-
}
58-
const raw = cp.execSync(`sqlite3 -json "${dbPath}" "${finalSql.replace(/"/g, '\\"')}"`, {
59-
encoding: 'utf8',
60-
timeout: 3000,
61-
killSignal: 'SIGKILL',
62-
});
63-
return JSON.parse(raw || '[]') as Row[];
64-
} catch {
65-
throw new Error(
66-
`Cannot read SQLite database at ${dbPath}.\n` +
67-
`Install better-sqlite3: npm install better-sqlite3\n` +
68-
`Or install sqlite3 CLI: https://sqlite.org/download.html\n` +
69-
`Original error: ${primaryErr}`
70-
);
71-
}
50+
} catch {
51+
return []; // silently return empty — never spawn a subprocess
7252
}
7353
}
7454

0 commit comments

Comments
 (0)