Docusaurus 2 memory leak with custom remark plugin. #4978
Labels
bug
An error in the Docusaurus core causing instability or issues with its execution
domain: markdown
Related to Markdown parsing or syntax
🐛 Bug Report
Recently our build have been exploding with a memory leak (unfortunately I can't pinpoint it exactly, CI seems to still build due to caching, but even the current master will OOM without cache).
Prerequisites
npm run clear
oryarn clear
command.rm -rf node_modules yarn.lock package-lock.json
and re-installing packages.Description
We are using https://github.com/phryneas/remark-typescript-tools to transpile our TS example code down to JS and typecheck it in the process.
The module exports, like every remark plugin, an
attacher
"Plugin function" that is called with the options declared in thedocusaurus.config.js
.This attacher then creates a TypeScript compiler instance and returns a
transformer
function that can be called on files to do work.Now, I'm very sure that previously,
attacher
was called only once, the compiler instance was reused andtransformer
was called multiple times, once for each file.But what currently happens it that
attacher
is called 51 one times, creating 51 TypeScript compiler instances beforetransformer
is even called for the first time.With the default memory settings of 4GB, I don't even get to that point, setting it up to 16GB makes it work
Have you read the Contributing Guidelines on issues?
Yes
To Reproduce
Expected behavior
One instance of the plugin is created and reused.
Actual Behavior
and a stack trace for how
attacher
is called:At this point and with this knowledge, of course I can try to rewrite the plugin, but I am very sure that similar "memory-explosive" problems will occur with other remark plugins as well.
The text was updated successfully, but these errors were encountered: