fix: prevent metadata loss in multi-threaded md2md builds#1596
Merged
martyanovandrey merged 5 commits intomasterfrom Jan 21, 2026
Merged
fix: prevent metadata loss in multi-threaded md2md builds#1596martyanovandrey merged 5 commits intomasterfrom
martyanovandrey merged 5 commits intomasterfrom
Conversation
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.
fix: prevent metadata loss when file is both entry and include
Problem
When building documentation in
md2mdmode, files that are both a TOC entry and included by another file could lose their metadata (like__systemvariables).This issue is especially noticeable in multi-threaded builds, where processing order is non-deterministic. The metadata loss appears random — sometimes present, sometimes missing — depending on which thread writes last.
Root Cause
The issue occurs because the same file can be written twice:
The last write wins. If the include write happens after the entry write, all metadata is lost.
Example scenario:
Processing order:
In single-threaded mode, the order is deterministic (though still incorrect for affected files). In multi-threaded mode, the order depends on thread scheduling, making the bug appear intermittent.
How to Reproduce
Create a file that is both:
toc.yamlas an entry{% include %}in another fileBuild with
--output-format=md --add-system-metaCheck output — the file may be missing
__systemmetadata depending on processing orderSolution
Add YAML frontmatter when writing include files in
output-md:Now both writers (entry and include) produce the same output with frontmatter, so the write order no longer matters.