Skip to content

fix: renderInlineAsync no longer routes async render through patched sync renderInline (#35) - #36

Merged
serkodev merged 1 commit into
serkodev:mainfrom
antfubot:fix/renderinlineasync-sync-fallback
Aug 24, 2026
Merged

serkodev merged 1 commit into
serkodev:mainfrom
antfubot:fix/renderinlineasync-sync-fallback

Conversation

@antfubot

Copy link
Copy Markdown
Contributor

What

Renderer.renderInlineAsync() (new in 1.2.0) delegated to a monkey-patched sync renderInline whenever one was present. When a plugin wraps both renderInline and renderInlineAsync — a natural, async-aware pattern (e.g. @comark/markdown-it) — the async render was routed back through the sync path, which throws Renderer.renderInline: async rule detected in the presence of async inline rules (Shiki, KaTeX, etc.).

This scopes the sync fallback so it is honored only when renderInlineAsync itself is not patched. If a plugin also wraps renderInlineAsync, its async-aware wrapper has already run its preprocessing by the time control reaches the prototype method, so delegating to the sync path is both unnecessary and unsafe — instead the proper async loop runs.

The existing behavior of honoring a plugin that patches only renderInline is preserved.

Fixes #35.

Why

This breaks real-world downstreams: Slidev decks with comark: true apply @comark/markdown-it on top of async Shiki/KaTeX inline rules, so slidev build fails on any install resolving markdown-exit@1.2.0 (slidevjs/slidev#2717 pinned to 1.1.0-beta.2 as a stopgap).

Verification

Added a TDD regression test that wraps both inline render methods with an async code_inline rule (the reproduction from the issue) — it fails before the fix with the reported error and passes after. Full suite (966 tests), lint, build, and typecheck all pass.

This PR was created with the help of an agent.

@antfubot
antfubot force-pushed the fix/renderinlineasync-sync-fallback branch from 5999bcb to 4cc47fb Compare August 24, 2026 06:11

@antfu antfu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Human reviewed :P

@serkodev
serkodev merged commit 42c1916 into serkodev:main Aug 24, 2026
4 checks passed
@codspeed

codspeed Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 6 untouched benchmarks


Comparing antfubot:fix/renderinlineasync-sync-fallback (4cc47fb) with main (ba91645)

Open in CodSpeed

@serkodev

Copy link
Copy Markdown
Owner

This PR is included in the v1.2.1 release. @antfu @antfubot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

renderInlineAsync() falls back to sync renderInline, throwing "async rule detected" when a plugin wraps the renderer

3 participants