diff --git a/src/domain/graph/resolve.ts b/src/domain/graph/resolve.ts index 06c62141..8588c7c9 100644 --- a/src/domain/graph/resolve.ts +++ b/src/domain/graph/resolve.ts @@ -1,5 +1,6 @@ import fs from 'node:fs'; import path from 'node:path'; +import { debug } from '../../infrastructure/logger.js'; import { loadNative } from '../../infrastructure/native.js'; import { normalizePath } from '../../shared/constants.js'; import type { BareSpecifier, BatchResolvedMap, ImportBatchItem, PathAliases } from '../../types.js'; @@ -64,7 +65,10 @@ function getPackageExports(packageDir: string): any { const exports = pkg.exports ?? null; _exportsCache.set(packageDir, exports); return exports; - } catch { + } catch (e) { + debug( + `readPackageExports: failed to read package.json in ${packageDir}: ${(e as Error).message}`, + ); _exportsCache.set(packageDir, null); return null; } @@ -515,8 +519,10 @@ export function resolveImportPath( // unresolved ".." components (PathBuf::components().collect() doesn't // collapse parent refs). Apply the remap on the JS side as a fallback. return remapJsToTs(normalized, rootDir); - } catch { - // fall through to JS + } catch (e) { + debug( + `resolveImportPath: native resolution failed, falling back to JS: ${(e as Error).message}`, + ); } } return resolveImportPathJS(fromFile, importSource, rootDir, aliases); @@ -535,8 +541,10 @@ export function computeConfidence( if (native) { try { return native.computeConfidence(callerFile, targetFile, importedFrom || null); - } catch { - // fall through to JS + } catch (e) { + debug( + `computeConfidence: native computation failed, falling back to JS: ${(e as Error).message}`, + ); } } return computeConfidenceJS(callerFile, targetFile, importedFrom); @@ -575,7 +583,8 @@ export function resolveImportsBatch( map.set(`${r.fromFile}|${r.importSource}`, resolved); } return map; - } catch { + } catch (e) { + debug(`batchResolve: native batch resolution failed: ${(e as Error).message}`); return null; } } diff --git a/src/domain/parser.ts b/src/domain/parser.ts index ecbc3f88..0497d5e9 100644 --- a/src/domain/parser.ts +++ b/src/domain/parser.ts @@ -442,7 +442,8 @@ async function backfillTypeMap( if (!code) { try { code = fs.readFileSync(filePath, 'utf-8'); - } catch { + } catch (e) { + debug(`backfillTypeMap: failed to read ${filePath}: ${(e as Error).message}`); return { typeMap: new Map(), backfilled: false }; } } @@ -458,7 +459,9 @@ async function backfillTypeMap( if (extracted?.tree && typeof extracted.tree.delete === 'function') { try { extracted.tree.delete(); - } catch {} + } catch (e) { + debug(`backfillTypeMap: WASM tree cleanup failed: ${(e as Error).message}`); + } } } } @@ -571,14 +574,16 @@ export async function parseFilesAuto( symbols.typeMap = extracted.symbols.typeMap; symbols._typeMapBackfilled = true; } - } catch { - /* skip — typeMap is a best-effort backfill */ + } catch (e) { + debug(`batchExtract: typeMap backfill failed: ${(e as Error).message}`); } finally { // Free the WASM tree to prevent memory accumulation across repeated builds if (extracted?.tree && typeof extracted.tree.delete === 'function') { try { extracted.tree.delete(); - } catch {} + } catch (e) { + debug(`batchExtract: WASM tree cleanup failed: ${(e as Error).message}`); + } } } } diff --git a/src/infrastructure/config.ts b/src/infrastructure/config.ts index fb162f15..d6a7c609 100644 --- a/src/infrastructure/config.ts +++ b/src/infrastructure/config.ts @@ -310,8 +310,10 @@ function resolveWorkspaceEntry(pkgDir: string): string | null { const candidate = path.resolve(pkgDir, idx); if (fs.existsSync(candidate)) return candidate; } - } catch { - /* ignore */ + } catch (e) { + debug( + `resolveWorkspaceEntry: package.json probe failed for ${pkgDir}: ${(e as Error).message}`, + ); } return null; } @@ -344,8 +346,8 @@ export function detectWorkspaces(rootDir: string): Map { } } } - } catch { - /* ignore */ + } catch (e) { + debug(`detectWorkspaces: failed to parse pnpm-workspace.yaml: ${(e as Error).message}`); } } @@ -363,8 +365,8 @@ export function detectWorkspaces(rootDir: string): Map { // Yarn classic format: { packages: [...], nohoist: [...] } patterns.push(...ws.packages); } - } catch { - /* ignore */ + } catch (e) { + debug(`detectWorkspaces: failed to parse package.json workspaces: ${(e as Error).message}`); } } } @@ -379,8 +381,8 @@ export function detectWorkspaces(rootDir: string): Map { if (Array.isArray(lerna.packages)) { patterns.push(...lerna.packages); } - } catch { - /* ignore */ + } catch (e) { + debug(`detectWorkspaces: failed to parse lerna.json: ${(e as Error).message}`); } } } diff --git a/src/infrastructure/native.ts b/src/infrastructure/native.ts index ed29ae3d..a397405f 100644 --- a/src/infrastructure/native.ts +++ b/src/infrastructure/native.ts @@ -10,6 +10,7 @@ import { createRequire } from 'node:module'; import os from 'node:os'; import { EngineError } from '../shared/errors.js'; import type { NativeAddon } from '../types.js'; +import { debug } from './logger.js'; let _cached: NativeAddon | null | undefined; // undefined = not yet tried, null = failed, NativeAddon = module let _loadError: Error | null = null; @@ -26,7 +27,9 @@ function detectLibc(): 'gnu' | 'musl' { if (files.some((f: string) => f.startsWith('ld-musl-') && f.endsWith('.so.1'))) { return 'musl'; } - } catch {} + } catch (e) { + debug(`detectLibc: failed to read /lib: ${(e as Error).message}`); + } return 'gnu'; } @@ -92,7 +95,10 @@ export function getNativePackageVersion(): string | null { try { const pkgJson = _require(`${pkg}/package.json`) as { version?: string }; return pkgJson.version || null; - } catch { + } catch (e) { + debug( + `getNativePackageVersion: failed to read package.json for ${pkg}: ${(e as Error).message}`, + ); return null; } }