Comment

Comment by appsoftware

While building AS Notes (A wikilink-based knowledge management VS Code extension - https://github.com/appsoftwareltd/as-notes) - I ran into a subtle and genuinely interesting bug involving WebAssembly linear memory.

TLDR: sql.js loads SQLite into a WASM module with a single linear memory buffer. After indexing 18,000+ files that memory is large and fragmented. Reconstructing a Database() object on that same heap fails with "memory access out of bounds". The fix is a build-time esbuild plugin that injects a resetCache() function into the sql.js bundle, allowing the WASM module to be fully discarded and reloaded from scratch on rebuild.

parent appsoftware 8 months ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton