Skip to content

Commit c032d64

Browse files
zknprclaude
andcommitted
chore(web): remove #418 diagnostic instrumentation (1.4.0)
#418 is fixed (1.3.9 CommonJS build) and verified in real vscode.dev, so the temporary open-sequence logging added in 1.3.8 is no longer needed. Removes the diagStep/diag helpers, per-await step logging, the read-path facade wrappers, and the loadDatabaseFiles diag parameter. The browser establishConnection and loadDatabaseFiles are restored byte-identical to the post-1.3.7 in-process form (verified: git diff vs f16680a is empty). The in-process engine itself is unchanged. Bumps 1.3.9 -> 1.4.0. Verified: build OK (extension-browser.js still exports activate via cjs; worker-free; no '#418 web-open' markers); tsc --noEmit clean; npm test 334/334. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 6f499f2 commit c032d64

3 files changed

Lines changed: 20 additions & 76 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 1.4.0
4+
5+
### Changed
6+
7+
- **Removed the temporary #418 web open-sequence diagnostic logging.** The instrumentation added in 1.3.8 to locate the VS Code for Web loading hang is no longer needed now that the root cause is fixed (1.3.9) and verified in vscode.dev. The browser connection path (`establishConnection`, `loadDatabaseFiles`) is restored to its clean form; opening a database no longer writes `[#418 web-open]` step logs to the output channel.
8+
39
## 1.3.9
410

511
### Bug Fixes

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "sqlite-explorer",
44
"displayName": "SQLite Explorer",
55
"description": "A powerful SQLite database viewer and editor for VS Code",
6-
"version": "1.3.9",
6+
"version": "1.4.0",
77
"publisher": "zknpr",
88
"license": "MIT",
99
"repository": {

src/workerFactory.ts

Lines changed: 13 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -210,52 +210,15 @@ async function createInProcessWasmDatabaseConnection(
210210
forceReadOnly?: boolean,
211211
autoCommit?: boolean
212212
) {
213-
// ---- DIAGNOSTIC INSTRUMENTATION (issue #418, web-only hang) ----
214-
// The in-process browser path opens a DB through a sequence of awaits in the
215-
// sandboxed web extension host, where a stall is invisible to DevTools and to
216-
// network inspection. Log each step to the SQLite Explorer output channel
217-
// (revealed up front) so the LAST "start" with no matching "ok" pinpoints the
218-
// hanging call. Each step is wrapped so a thrown error surfaces in the UI
219-
// instead of leaving the editor spinning forever.
220-
GlobalOutputChannel?.show?.(true);
221-
// Log to BOTH the output channel (if wired) and console — in the web
222-
// extension host, console output is captured by the "Extension Host
223-
// (Worker)" output channel, so we get the trace even if our own channel
224-
// is not yet created when the editor opens.
225-
const diag = (m: string) => {
226-
const line = `[#418 web-open] ${m}`;
227-
GlobalOutputChannel?.appendLine(line);
228-
console.log(line);
229-
};
230-
const diagStep = async <T>(label: string, fn: () => PromiseLike<T>): Promise<T> => {
231-
const t0 = Date.now();
232-
diag(`▶ ${label} … start`);
233-
try {
234-
const r = await fn();
235-
diag(` ✓ ${label} ok (${Date.now() - t0}ms)`);
236-
return r;
237-
} catch (err) {
238-
const msg = err instanceof Error ? (err.stack || err.message) : String(err);
239-
diag(` ✗ ${label} FAILED (${Date.now() - t0}ms): ${msg}`);
240-
void vsc.window.showErrorMessage(`SQLite Explorer: failed at "${label}" — ${err instanceof Error ? err.message : String(err)}`);
241-
throw err;
242-
}
243-
};
244-
245-
diag(`establishConnection: ${displayName} (uri.scheme=${fileUri.scheme})`);
246-
247213
// Browser mode always reads database bytes through the VS Code filesystem.
248214
// There is no file-path fast path because the web extension host cannot
249215
// access local disk paths directly.
250-
const [dbContent, walContent] = await diagStep('loadDatabaseFiles', () => loadDatabaseFiles(fileUri, diag));
251-
diag(` db bytes=${dbContent?.byteLength ?? 'null'} wal bytes=${walContent?.byteLength ?? 'null'}`);
216+
const [dbContent, walContent] = await loadDatabaseFiles(fileUri);
252217

253218
// Preload sql.js WASM bytes from the extension assets directory so
254219
// WebAssembly instantiation does not depend on worker-relative URLs.
255220
const wasmUri = vsc.Uri.joinPath(extensionUri, 'assets', 'sqlite3.wasm');
256-
diag(` wasmUri=${wasmUri.toString()}`);
257-
const wasmContent = await diagStep('readFile(sqlite3.wasm)', () => vsc.workspace.fs.readFile(wasmUri));
258-
diag(` wasm bytes=${wasmContent?.byteLength ?? 'null'}`);
221+
const wasmContent = await vsc.workspace.fs.readFile(wasmUri);
259222

260223
const initConfig: DatabaseInitConfig = {
261224
content: dbContent,
@@ -267,8 +230,7 @@ async function createInProcessWasmDatabaseConnection(
267230
queryTimeout: getQueryTimeout()
268231
};
269232

270-
const result = await diagStep('initializeDatabase (sql.js engine)', () => endpoint.initializeDatabase(displayName, initConfig));
271-
diag(`establishConnection complete (isReadOnly=${result.isReadOnly})`);
233+
const result = await endpoint.initializeDatabase(displayName, initConfig);
272234

273235
const operationsFacade: DatabaseOperations = {
274236
engineKind: Promise.resolve('wasm'),
@@ -298,25 +260,20 @@ async function createInProcessWasmDatabaseConnection(
298260
endpoint.updateCellBatch(table, updates),
299261
addColumn: (table: string, column: string, type: string, defaultValue?: string) =>
300262
endpoint.addColumn(table, column, type, defaultValue),
301-
// The read-path methods below run during the loading screen (viewer.js
302-
// awaits ping -> fetchSchema -> fetchTableCount/fetchTableData on open).
303-
// Wrap them in diagStep so a stall in any of THEM — not just
304-
// establishConnection's awaits — is pinpointed by the last unmatched
305-
// "start" in the trace. (#418 diagnostic)
306263
fetchTableData: (table: string, options: TableQueryOptions) =>
307-
diagStep(`fetchTableData(${table})`, () => endpoint.fetchTableData(table, options)),
264+
endpoint.fetchTableData(table, options),
308265
fetchTableCount: (table: string, options: TableCountOptions) =>
309-
diagStep(`fetchTableCount(${table})`, () => endpoint.fetchTableCount(table, options)),
266+
endpoint.fetchTableCount(table, options),
310267
fetchSchema: () =>
311-
diagStep('fetchSchema', () => endpoint.fetchSchema()),
268+
endpoint.fetchSchema(),
312269
getTableInfo: (table: string) =>
313-
diagStep(`getTableInfo(${table})`, () => endpoint.getTableInfo(table)),
270+
endpoint.getTableInfo(table),
314271
getPragmas: () =>
315-
diagStep('getPragmas', () => endpoint.getPragmas()),
272+
endpoint.getPragmas(),
316273
setPragma: (pragma: string, value: CellValue) =>
317274
endpoint.setPragma(pragma, value),
318275
ping: () =>
319-
diagStep('ping', () => endpoint.ping()),
276+
endpoint.ping(),
320277
writeToFile: (path: string) =>
321278
endpoint.writeToFile(path)
322279
};
@@ -546,16 +503,10 @@ async function createWorkerBackedWasmDatabaseConnection(
546503
* Load database file and optional WAL file.
547504
*
548505
* @param uri - Database file URI
549-
* @param diag - Optional diagnostic logger (#418). When provided, each internal
550-
* filesystem await (stat, main readFile, optional -wal readFile) is logged
551-
* separately so a stall in one specific call is identifiable. The -wal read is
552-
* a prime suspect: reading a (usually nonexistent) `-wal` over vscode-vfs may
553-
* never settle in the web extension host.
554506
* @returns Tuple of [database content, WAL content]
555507
*/
556508
async function loadDatabaseFiles(
557-
uri: vsc.Uri,
558-
diag?: (message: string) => void
509+
uri: vsc.Uri
559510
): Promise<[Uint8Array | null, Uint8Array | null]> {
560511
// Untitled documents start empty
561512
if (uri.scheme === 'untitled') {
@@ -565,30 +516,17 @@ async function loadDatabaseFiles(
565516
const maxSize = getMaximumFileSizeBytes();
566517

567518
// Check file size
568-
diag?.('▶ fs.stat(db) … start');
569519
const fileStat = await Promise.resolve(vsc.workspace.fs.stat(uri)).catch(() => ({ size: 0 }));
570-
diag?.(` ✓ fs.stat(db) ok (size=${fileStat.size})`);
571520
if (maxSize !== 0 && fileStat.size > maxSize) {
572521
throw new Error(`File size (${(fileStat.size / (1024 * 1024)).toFixed(2)} MB) exceeds the maximum allowed size (${(maxSize / (1024 * 1024)).toFixed(2)} MB). Configure 'sqliteExplorer.maxFileSize' to increase the limit.`);
573522
}
574523

575524
// Construct WAL file URI
576525
const walUri = uri.with({ path: uri.path + '-wal' });
577526

578-
// Read both files concurrently. Log each independently so a hang in the main
579-
// DB read vs. the optional -wal read is distinguishable in the #418 trace.
527+
// Read both files concurrently
580528
return Promise.all([
581-
(async () => {
582-
diag?.('▶ fs.readFile(db) … start');
583-
const r = await vsc.workspace.fs.readFile(uri);
584-
diag?.(` ✓ fs.readFile(db) ok (${r?.byteLength ?? 'null'} bytes)`);
585-
return r;
586-
})(),
587-
(async () => {
588-
diag?.('▶ fs.readFile(-wal, optional) … start');
589-
const r = await Promise.resolve(vsc.workspace.fs.readFile(walUri)).catch(() => null);
590-
diag?.(` ✓ fs.readFile(-wal) settled (${r ? r.byteLength + ' bytes' : 'absent'})`);
591-
return r;
592-
})()
529+
vsc.workspace.fs.readFile(uri),
530+
Promise.resolve(vsc.workspace.fs.readFile(walUri)).catch(() => null)
593531
]);
594532
}

0 commit comments

Comments
 (0)