Skip to content

fix: honor per-call async options when composing hooks - #4139

Open
xiehuanyi wants to merge 1 commit into
markedjs:masterfrom
xiehuanyi:fix/per-call-async-hooks-r2-20261013
Open

xiehuanyi wants to merge 1 commit into
markedjs:masterfrom
xiehuanyi:fix/per-call-async-hooks-r2-20261013

Conversation

@xiehuanyi

Copy link
Copy Markdown

Marked version: master cdbdc0122ab83b2b97560944bf009a22cfb78b05 (18.1.1)

Markdown flavor: n/a — JavaScript hooks API

Description

Expectation

Calling parse(markdown, { async: true }) should await composed hooks and honor an async hook returning false to use the previous provider.

Result

Hook composition checks the instance default async flag instead of the active parse options. When async mode is enabled only on a parse call, an async hook passes a Promise into an earlier synchronous hook, or an async provider's false fallback is skipped. The parse rejects with errors such as markdown.toUpperCase is not a function.

What was attempted

Use the parse options already stored on the hooks object to select async composition. Add regressions for chained preprocess/postprocess hooks and an asynchronous parser-provider fallback while keeping the instance default synchronous.

Validation: all three regressions fail before the fix. Full npm test passes, including 1911 specification tests and 202 unit tests, build/docs, UMD/CJS smoke checks, types and lint. git diff --check passes.

Discovery and implementation: automated OpenAI gpt-6.1-sol source review, xhigh reasoning.

Contributor

  • Tests exist to ensure functionality and minimize regression.
  • This is a bug fix to existing async options; no new feature documentation is required.

Committer

  • CI is green (pending after publication).
  • Squash and Merge PR following conventional commit guidelines (maintainer action).

Copilot AI balanced review requested due to automatic review settings October 13, 2026 08:58
@vercel

vercel Bot commented Oct 13, 2026

Copy link
Copy Markdown

@xiehuanyi is attempting to deploy a commit to the MarkedJS Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@vercel

vercel Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
marked-website Ready Ready Preview Oct 17, 2026 3:46pm UTC

Request Review

@UziTech UziTech left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice catch! 💯

This branch was successfully deployed

1 active deployment
Preview — 5348e4fe Deployed Oct 17, 2026 by vercel[bot]
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.

3 participants