-
-
Notifications
You must be signed in to change notification settings - Fork 374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RuntimeError: memory access out of bounds #567
Comments
From your code, I found that you are calling |
I was having this issue too, trying to use this with Next.js in a Server Component. @souporserious shared his solution from MDXTS, and it seems to work great: import React from 'react';
import { getHighlighter } from 'shiki';
let highlighter: Awaited<ReturnType<typeof getHighlighter>> | null =
null;
const getCachedHighlighter = React.cache(async () => {
if (highlighter === null) {
highlighter = await getHighlighter({
// options here
});
}
return highlighter;
});
// Call `await getCachedHighlighter()` whenever you need it in your component(s). |
I am having the same issue, but in my case I am using Someone has an idea on a possible fix? |
Cached highlighter should still work with |
@souporserious the problem is that rehypePlugins: [
[
rehypeShiki,
// 👇 No highlighter
{ theme: "one-dark-pro" } satisfies RehypeShikiOptions,
],
] Do you know if this can be solved? |
The official rehype plugin should automatically cache the shiki instance, it's more likely you are processing a large amount of files that your machine can't handle, or a wrong usage (like re-constructing the MDX processor in every file). You can open another issue and provide sufficient information for debugging. |
Just a quick followup: With the solution I shared above, I still occasionally get the out-of-memory issue. I think it's because I have two separate highlighters (a "light" one that runs in-browser and only has 1 theme and a couple of languages, and a "full" one with many different languages). It's fine in my case since I'm running Shiki at compile-time, so if 1 in 500 builds fail, that's not a big deal. But if I was doing this with an on-demand SSR strategy, it might give me pause. It’s likely user error on my part, but wanted to mention this to be fully transparent about how well the solution I shared works. |
Validations
Describe the bug
We're trying to migrate the Waku website to Shiki (v1.0.0-beta.0) and encountering the same
RuntimeError: memory access out of bounds
issue that others have reported. It's affecting both local builds and Vercel deployments.Reproduction
dai-shi/waku#437
Contributes
The text was updated successfully, but these errors were encountered: