Skip to content

fix: await promise arrays from walkTokens extensions - #4153

Merged
UziTech merged 2 commits into
markedjs:masterfrom
Plastic-time:fix/walktokens-promise-arrays
Nov 2, 2026
Merged

UziTech merged 2 commits into
markedjs:masterfrom
Plastic-time:fix/walktokens-promise-arrays

Conversation

@Plastic-time

@Plastic-time Plastic-time commented Oct 20, 2026 •

Copy link
Copy Markdown

Marked version: 18.1.1 / current master
Markdown flavor: n/a (extension API)

walkTokens callbacks may return an array of promises. When registered with marked.use(), that array is currently wrapped in another array, so the async parse path's Promise.all() does not await its promises. For example, a callback returning [fetchData().then(() => updateToken(token))] can leave the rendered output unchanged even after await marked.parse(...).

Use the existing pushValues helper when collecting the newly registered callback's return value, matching how earlier callbacks and traversal results are collected. This retains callback order and the existing linear-time accumulation. Update the public extension callback type to accept the existing array return contract and compile a regression against the public declarations.

Validation on Windows / Node 24.20.0:

  • Both new regressions fail on the unchanged source: nested result arrays and rendering before token updates.
  • Regressions cover composed callbacks, parse, and parseInline.
  • Full npm test passed: build/docs, specification tests, unit tests, UMD/CJS checks, type checks, and lint.

Contributor

  • Tests exist to ensure functionality and minimize regression.
  • This fixes the existing callback return contract; no new API.

AI disclosure: Codex (GPT-6) assisted with investigation, implementation, tests, and this description. Prepared for maintainer review.

Readiness verification — 2026-10-22 UTC

Verified commit 781b3f6be57349318b199d98cd1085412f6dd26e against the current upstream diff and contribution guidance. No unresolved review threads or merge conflicts were present at this check.

npm test passed on Windows / Node 24.20.0, including clean build/docs, 1911 spec tests, 201 unit tests, UMD/CJS checks, declaration/package checks and lint. The current head includes the public MarkedExtension.walkTokens array return type and a public-declaration compile test, in addition to the runtime fix. No additional source changes were needed; the checkout remains clean.

git diff --check passes. Local verification is separate from upstream CI. The upstream workflow still requires maintainer approval; it has not been counted as a successful run.

@vercel

vercel Bot commented Oct 20, 2026

Copy link
Copy Markdown

@Plastic-time 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 20, 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 26, 2026 6:15am 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! 💯

@UziTech
UziTech merged commit c38704c into markedjs:master Nov 2, 2026
8 checks passed
github-actions Bot pushed a commit that referenced this pull request Nov 2, 2026
## [18.1.3](v18.1.2...v18.1.3) (2026-11-02)

### Bug Fixes

* allow trailing tabs after a setext heading underline ([#4152](#4152)) ([1f1b480](1f1b480))
* avoid quadratic scan for unmatched emphasis delimiters ([#4103](#4103)) ([eab1e48](eab1e48)), closes [#4099](#4099)
* await promise arrays from walkTokens extensions ([#4153](#4153)) ([c38704c](c38704c))
* **cli:** honor defaults and config when outputting tokens ([#4146](#4146)) ([9470e8f](9470e8f))
* collapse internal whitespace when normalizing link labels ([#4157](#4157)) ([02c73e8](02c73e8))
* do not allow a blank line inside a link reference definition label ([#4165](#4165)) ([f3d21af](f3d21af))
* don't treat an escaped ) or quote as an inline link or title closer ([#4151](#4151)) ([9cb84e0](9cb84e0))
* end a list item before a lazy line after an html block ([#4159](#4159)) ([7ba42f4](7ba42f4))
* end blockquote before a lazy line after a table ([#4161](#4161)) ([e7dcf52](e7dcf52))
* isolate extension names from Object.prototype ([#4177](#4177)) ([5cb03bd](5cb03bd))
* keep a block quote open after a lazy line in a nested block quote ([#4175](#4175)) ([1d7272f](1d7272f))
* only close a code fence with the opening fence character ([#4164](#4164)) ([1d4d8fe](1d4d8fe))
* preserve zero-valued custom renderer results ([#4162](#4162)) ([e43ceef](e43ceef))
* recognize task list items when a tab follows the checkbox ([#4163](#4163)) ([64a299d](64a299d))
* start a GFM www autolink only at a word boundary ([#4166](#4166)) ([84beefb](84beefb))

### Performance Improvements

* fix backtracking in padantic html ([#4173](#4173)) ([2d4a23c](2d4a23c))

This branch was successfully deployed

1 active deployment
Preview — 781b3f6b Deployed Oct 26, 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.

2 participants