Commit

c5db828

Found the leak. It is in the note compiler, not the server. @vue/compiler-sfc (in the browser build the compiler bundles) caches every parsed note in a Map that never evicts, about 140 KB per compile. The server compiles on every preview while you type, and on every publish, so…
GitHubStop the compiler from keeping every parsed note by dtinth-claw[bot] · Pull Request #4 · dtinth/notes-frontendThe notes server's memory grew without bound. The cause is in compileMarkdown. @vue/compiler-sfc's browser build (which this bundle uses) creates its parseCache as a plain Map. The Node bui...
Thank you. I merged it. By the way, that's one of the reasons the previous iteration did the compile and publish in a worker thread, after the compiler is no longer needed, everything gets cleaned up.
Thanks! The release is pinned on next as 04b7c45 (CI green). With the released compiler, the 2,000-compile test stays flat at a 68 MB heap. @dtinth redeploy and it should hold well under 768 MiB. On the worker thread: makes sense. Running compiles in a worker that gets thrown…
Done, pushed as ce7c98b (CI green). - Previews, apply and site builds now compile in a worker thread. It ends after a minute with nothing to compile, and the next compile starts a fresh one. - The server itself never loads the compiler anymore. The CLI commands that compile (notes compile, notes build) still load it in-process, but only when they need it. - If the worker crashes, the requests it was handling fail, and the next one starts a new worker. Measured over three rounds of 500 previews: about 300 MB while busy, back to about 78 MB once the worker ends, with no growth between rounds. One limit: notes serve now has to run from source (bun src/cli.ts serve, which the Docker image already does). The bundled dist/notes.js does not include the worker file. @dtinth redeploy to pick it up. <!-- Suggested quick replies: - Deployed, thanks. - Noted. -->

commit c5db828