Skip to content

fix(cli): await config functions before parsing - #4138

Open
YIOYIOIOI wants to merge 1 commit into
markedjs:masterfrom
YIOYIOIOI:fix/await-cli-config-functions
Open

YIOYIOIOI wants to merge 1 commit into
markedjs:masterfrom
YIOYIOIOI:fix/await-cli-config-functions

Conversation

@YIOYIOIOI

Copy link
Copy Markdown

Marked version: 18.1.1 (cdbdc012)

Markdown flavor: n/a (CLI configuration)

Description

The CLI awaits loading a config module but ignores the Promise returned by an exported config function. A function that defers extension setup can therefore finish after parsing, or never finish because the CLI exits first. Initialization failures also produce successful output and exit status 0.

For example, this config should enable line breaks before rendering:

import { setImmediate } from 'node:timers/promises';

export default async marked => {
  await setImmediate();
  marked.use({ breaks: true });
};

For input line1\nline2, master emits <p>line1\nline2</p> instead of <p>line1<br>line2</p>.

Await the config callback in runConfig() so setup finishes before parsing and rejected callbacks reach the existing CLI error handler. Document the behavior and add regressions for asynchronous setup and rejection, plus a synchronous callback control. The asynchronous tests launch the actual CLI in separate processes to check output and exit status.

Validation

  • Both asynchronous regressions fail without the source change; the synchronous control passes.
  • npm test passes on Windows with Node 24.18.0: 1,911 spec executions, 202 unit tests, documentation build, UMD/CJS checks, type/export checks, and ESLint.
  • git diff --check passes.

Contributor

  • Test(s) exist to ensure functionality and minimize regression.
  • No tests required for this PR.
  • The configuration behavior is documented.

Committer

@vercel

vercel Bot commented Oct 13, 2026

Copy link
Copy Markdown

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

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Oct 13, 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 13, 2026 5:48pm UTC

Request Review

This branch was successfully deployed

1 active deployment
Preview — 61acb7a3 Deployed Oct 13, 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.

1 participant