Skip to content

fix(core): optimize report merging for large inline reports#2127

Draft
quanru wants to merge 1 commit intomainfrom
fix/core-report-merge-inline-perf
Draft

fix(core): optimize report merging for large inline reports#2127
quanru wants to merge 1 commit intomainfrom
fix/core-report-merge-inline-perf

Conversation

@quanru
Copy link
Collaborator

@quanru quanru commented Mar 12, 2026

Summary

  • merge inline report image scripts and dump extraction in a single streaming pass
  • keep one output file descriptor open during merge to avoid repeated destination reopen overhead
  • add a regression test that verifies each inline source report is scanned only once

Problem

Merging many large inline HTML reports became noticeably slower after the first several files because each source report was scanned twice and every copied image script reopened the merged output file.

Validation

  • pnpm run lint
  • npx nx build @midscene/core
  • pnpm --dir packages/core exec tsc --noEmit -p tsconfig.json
  • pnpm --dir packages/core exec vitest run tests/unit-test/report-merge-performance.test.ts
  • pnpm --dir packages/core exec vitest run tests/unit-test/merge-browser-parse.test.ts -t "step 2: verify merged report preserves directory mode with screenshots"
  • pnpm --dir packages/core exec vitest run tests/unit-test/report.test.ts -t "should merge 3 mocked reports|should merge directory mode reports and copy screenshots"
  • pnpm --dir packages/core exec vitest run tests/unit-test/report.test.ts -t "should use constant memory when merging reports with large inline images"

Notes

This change is intended to be safe for a prepatch release if you want to cut one after review.

@cloudflare-workers-and-pages
Copy link

Deploying midscene with  Cloudflare Pages  Cloudflare Pages

Latest commit: 12b37d3
Status: ✅  Deploy successful!
Preview URL: https://202a7af8.midscene.pages.dev
Branch Preview URL: https://fix-core-report-merge-inline.midscene.pages.dev

View logs

@quanru quanru marked this pull request as draft March 13, 2026 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant