Repository navigation
fix(primitive): dispose wasm memory for lazily embedded langs - #1322
Merged
Merged
Conversation
✅ Deploy Preview for shiki-matsu ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for shiki-next ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1322 +/- ##
=======================================
Coverage 89.82% 89.82%
=======================================
Files 81 81
Lines 3587 3588 +1
Branches 1028 1028
=======================================
+ Hits 3222 3223 +1
Misses 328 328
Partials 37 37 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
5 tasks done
rgodha24
marked this pull request as ready for review
September 30, 2026 16:16
antfu
approved these changes
Oct 1, 2026
antfu
pushed a commit
to SHUBHI-KUMARI/shiki
that referenced
this pull request
Oct 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
xbetween the brackts.Description
when you load a language that an already loaded grammar has in
embeddedLangsLazy(eg loadinghaskellwhilemarkdownis loaded),Registry.loadLanguagedrops the embedding grammar and rebuilds it, but never disposes the old one. with the oniguruma engine the old grammar's scanners just sit in wasm memory forever. they're also out of_grammarsat that point, sohighlighter.dispose()doesnt free them eitherthis causes issues on long lived servers running shiki, like mintlify's mdx compilation pipeline.
fix is to dispose the old grammar before dropping it. the rebuilt grammar is the same one shiki would use anyway so highlighting doesnt change
Linked Issues
fixes #1323
Additional context
added a test in
packages/primitive/test/registry.test.tsthat fails without the fix (old grammar'sdisposenever gets called). repro script + memory numbers are in #1323workaround: mintlify/mdx#66