fix(loader): stream HTML chunks incrementally with benchmark coverage#3145
Merged
Conversation
|
kuitos
marked this pull request as ready for review
July 12, 2026 14:00
This was referenced Jul 12, 2026
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.
Summary
TagTransformStreamflush safe HTML immediately while retaining only a possible cross-chunk tag prefixRoot cause
TagTransformStreampreviously enqueued data only when a<head>replacement changed the current buffer. Once the structural head had already been replaced, later chunks containing the micro-app core had no replacement and remained buffered until EOF. This defeated incremental HTML delivery.The new scanner consumes each structural replacement once across the stream, preserves later matching literals in script raw text, rejects ambiguous replacement patterns, and keeps the pending buffer bounded by the longest unconsumed tag prefix.
Performance
Formal interleaved comparison, 100 valid samples per revision:
Paired relative delta: -38.52%, bootstrap 95% CI [-39.36%, -37.06%].
A/A calibration passed at +0.29%, 95% CI [-0.17%, +0.81%]. There were no invalid samples.
Validation
pnpm --filter @qiankunjs/loader testpnpm run eslintpnpm run benchmark:compareThe repository-wide
pnpm testreached the unrelated bundler-plugin webpack fixture, then stopped because the execution environment did not provide the systemnpmbinary; all affected loader/shared/sandbox tests passed independently.