-
-
Notifications
You must be signed in to change notification settings - Fork 362
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
"TypeError: onigBinding.UTF8ToString is not a function" after some time / parallel requests in Next.js #693
Comments
Same error, but I'm using When I reverted to the code that I could deploy yesterday and redeployed it, it still failed. I'm not sure if this problem is caused by By the way, I don't think this title describes the error very well😂 |
FTR, I ran into the same issue while trying to use the shiki rehype plugin in a My investigations tend to show this issue is linked to the memory usage. Indeed the node process memory kept increasing (until around 2.3 GB) until this error was thrown. By playing with the Finally, I managed to workaround this issue by splitting the files I had to process into several chunks, spawning a new |
Ran into the same problem in an application that uses |
@Neo-Zhixing I believe the code responsible for this (at least, according to the stacktrace) was introduced in shiki |
Thanks! That was fast. |
Thanks for the update! For those using the import { unified } from 'unified'
import remarkParse from 'remark-parse'
import remarkRehype from 'remark-rehype'
import rehypeStringify from 'rehype-stringify'
import rehypeShikiFromHighlighter from '@shikijs/rehype/core'
import { getHighlighterCore } from 'shiki/core'
const highlighter = await getHighlighterCore({
themes: [
import('shiki/themes/vitesse-light.mjs')
],
langs: [
import('shiki/langs/javascript.mjs'),
],
loadWasm: import('shiki/wasm')
})
const raw = await fs.readFile('./input.md')
const file = await unified()
.use(remarkParse)
.use(remarkRehype)
.use(rehypeShikiFromHighlighter, highlighter, {
// ^^^^^^^^^^^ singleton instance
themes: {
light: 'vitesse-light',
dark: 'vitesse-dark',
}
})
.use(rehypeStringify)
.processSync(raw) // it's also possible to process synchronously Btw, maybe it would be worth mentioning this good practice in the plugin's doc page (https://shiki.style/packages/rehype) too @antfu , wdyt? |
Yeah sure, PR welcome. I also work on #702 to make it less confusing. |
This raises the question... is there a way to ask Shiki to dispose of that memory? |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [shiki](https://togithub.com/shikijs/shiki) ([source](https://togithub.com/shikijs/shiki/tree/HEAD/packages/shiki)) | [`1.6.5` -> `1.7.0`](https://renovatebot.com/diffs/npm/shiki/1.6.5/1.7.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/shiki/1.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/shiki/1.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/shiki/1.6.5/1.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/shiki/1.6.5/1.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>shikijs/shiki (shiki)</summary> ### [`v1.7.0`](https://togithub.com/shikijs/shiki/releases/tag/v1.7.0) [Compare Source](https://togithub.com/shikijs/shiki/compare/v1.6.5...v1.7.0) ##### 🚀 Features - **core**: Warning on too many instances, close [#​693](https://togithub.com/shikijs/shiki/issues/693) - by [@​antfu](https://togithub.com/antfu) in [https://github.com/shikijs/shiki/issues/693](https://togithub.com/shikijs/shiki/issues/693) [<samp>(412fe)</samp>](https://togithub.com/shikijs/shiki/commit/412fe10e) ##### 🐞 Bug Fixes - **core**: Add missing `UTF8ToString` function, close [#​693](https://togithub.com/shikijs/shiki/issues/693) - by [@​antfu](https://togithub.com/antfu) in [https://github.com/shikijs/shiki/issues/693](https://togithub.com/shikijs/shiki/issues/693) [<samp>(0c891)</samp>](https://togithub.com/shikijs/shiki/commit/0c89157f) ##### [View changes on GitHub](https://togithub.com/shikijs/shiki/compare/v1.6.5...v1.7.0) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/r4ai/r4ai.dev). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MTAuMSIsInVwZGF0ZWRJblZlciI6IjM3LjQxMC4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [shiki](https://togithub.com/shikijs/shiki) ([source](https://togithub.com/shikijs/shiki/tree/HEAD/packages/shiki)) | [`1.6.4` -> `1.7.0`](https://renovatebot.com/diffs/npm/shiki/1.6.4/1.7.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/shiki/1.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/shiki/1.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/shiki/1.6.4/1.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/shiki/1.6.4/1.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>shikijs/shiki (shiki)</summary> ### [`v1.7.0`](https://togithub.com/shikijs/shiki/releases/tag/v1.7.0) [Compare Source](https://togithub.com/shikijs/shiki/compare/v1.6.5...v1.7.0) ##### 🚀 Features - **core**: Warning on too many instances, close [#​693](https://togithub.com/shikijs/shiki/issues/693) - by [@​antfu](https://togithub.com/antfu) in [https://github.com/shikijs/shiki/issues/693](https://togithub.com/shikijs/shiki/issues/693) [<samp>(412fe)</samp>](https://togithub.com/shikijs/shiki/commit/412fe10e) ##### 🐞 Bug Fixes - **core**: Add missing `UTF8ToString` function, close [#​693](https://togithub.com/shikijs/shiki/issues/693) - by [@​antfu](https://togithub.com/antfu) in [https://github.com/shikijs/shiki/issues/693](https://togithub.com/shikijs/shiki/issues/693) [<samp>(0c891)</samp>](https://togithub.com/shikijs/shiki/commit/0c89157f) ##### [View changes on GitHub](https://togithub.com/shikijs/shiki/compare/v1.6.5...v1.7.0) ### [`v1.6.5`](https://togithub.com/shikijs/shiki/releases/tag/v1.6.5) [Compare Source](https://togithub.com/shikijs/shiki/compare/v1.6.4...v1.6.5) ##### 🐞 Bug Fixes - **rehype**: Fix type issues - by [@​remcohaszing](https://togithub.com/remcohaszing) in [https://github.com/shikijs/shiki/issues/699](https://togithub.com/shikijs/shiki/issues/699) [<samp>(0297c)</samp>](https://togithub.com/shikijs/shiki/commit/0297cd94) ##### 🏎 Performance - Improve performance for the `includeExplanation` option - by [@​thetarnav](https://togithub.com/thetarnav) in [https://github.com/shikijs/shiki/issues/701](https://togithub.com/shikijs/shiki/issues/701) [<samp>(966e7)</samp>](https://togithub.com/shikijs/shiki/commit/966e7e40) ##### [View changes on GitHub](https://togithub.com/shikijs/shiki/compare/v1.6.4...v1.6.5) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/ariakit/ariakit). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MTAuMSIsInVwZGF0ZWRJblZlciI6IjM3LjQxMC4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Found a proper way to dispose the instance #707, will landed in v1.8 |
Validations
Describe the bug
We experienced crashes in production when using shikijs in a Next.js 14 application in React Server Components.
Initially the rendering works, but after a few (parallel?) requests we have the following stacktrace and errors are returned in the rendering:
This is our code:
Where our syntax definition comes from https://github.com/networkteam/vscode-neos-fusion/blob/master/syntaxes/fusion.tmLanguage.json .
We could reproduce the behaviour with different Next.js versions (>=14) and by just refreshing constantly with F5 in the browser.
Our workaround for now is to use
unsable_cache
to cache the generated highlighted HTML.Reproduction
https://codesandbox.io/p/devbox/silly-grass-ngrp2h
Contributes
The text was updated successfully, but these errors were encountered: