Skip to content

Commit 03a91ca

Browse files
jahoomaclaude
andcommitted
Diagnostic dump in --smoke-tree-sitter handler
Round 6 (sibling-file approach) still failed on Windows. The smoke handler reports the same pre-init-state-empty error even though the build script copied tree-sitter.wasm next to the binary just before the smoke step ran. Add a diagnostic dump that prints process.execPath, dirname, the computed siblingPath, existsSync result, the dir listing, env var, and globalThis state. Whatever the next CI Windows run shows here is what we need to fix. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 6256069 commit 03a91ca

1 file changed

Lines changed: 27 additions & 2 deletions

File tree

cli/src/index.tsx

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,30 @@ async function main(): Promise<void> {
196196
globalThis as { __CODEBUFF_TREE_SITTER_WASM_BINARY__?: Uint8Array }
197197
).__CODEBUFF_TREE_SITTER_WASM_BINARY__
198198
const wasmPath = process.env.CODEBUFF_TREE_SITTER_WASM_PATH
199+
200+
// Diagnostic dump so CI logs (and bug reports) show exactly what
201+
// the runtime saw when smoke fails. process.execPath, the
202+
// siblingPath we expect, and what's actually in that directory.
203+
const fs = await import('fs')
204+
const path = await import('path')
205+
const execDir = path.dirname(process.execPath)
206+
const siblingPath = path.join(execDir, 'tree-sitter.wasm')
207+
let dirListing: string[] = []
208+
try {
209+
dirListing = fs.readdirSync(execDir)
210+
} catch (err) {
211+
dirListing = [`<readdir failed: ${err instanceof Error ? err.message : err}>`]
212+
}
213+
console.error(
214+
`[smoke diag] execPath=${process.execPath}\n` +
215+
`[smoke diag] execDir=${execDir}\n` +
216+
`[smoke diag] siblingPath=${siblingPath}\n` +
217+
`[smoke diag] siblingExists=${fs.existsSync(siblingPath)}\n` +
218+
`[smoke diag] dir contents (${dirListing.length}): ${dirListing.slice(0, 30).join(', ')}\n` +
219+
`[smoke diag] env.CODEBUFF_TREE_SITTER_WASM_PATH=${wasmPath ?? '<unset>'}\n` +
220+
`[smoke diag] globalThis wasmBinary bytes=${wasmBinary?.byteLength ?? 0}\n`,
221+
)
222+
199223
try {
200224
const { Parser } = await import('web-tree-sitter')
201225
if (wasmBinary) {
@@ -212,8 +236,9 @@ async function main(): Promise<void> {
212236
console.log(`tree-sitter smoke ok (locateFile, path=${wasmPath})`)
213237
} else {
214238
console.error(
215-
'tree-sitter smoke FAIL: pre-init published neither globalThis bytes nor an env path. ' +
216-
'The `with { type: \'file\' }` import returned falsy.',
239+
'tree-sitter smoke FAIL: pre-init published neither globalThis bytes ' +
240+
'nor an env path. Sibling tree-sitter.wasm not found relative to ' +
241+
'process.execPath. See diag above for the actual paths.',
217242
)
218243
process.exit(1)
219244
}

0 commit comments

Comments
 (0)