Repository navigation
fix: 大 PDF 分批拆页写盘,拆页崩溃不再无限循环 (#88) - #94
Merged
Merged
Conversation
pdfToPng holds every page it renders until it returns, so a large PDF kept all its PNGs in the main process. Pages are now rendered and written in batches of WORKER_CONFIG.splitter.renderBatchSize, and only their metadata is kept. Without a page range, pdf.js still decides where the document ends, because pdf-lib misses page tree nodes that lack a /Type. A split that brought the app down was re-queued on every start. Interrupted splits are now counted in Task.split_interrupt_count, and a task fails once it reaches maxInterruptedSplits. Retrying the task resets the count.
Conflicts in PDFSplitter.ts and its unit test. Batched rendering now goes through renderPdfPages (#92), which also decides the pdf.js log level, so the splitter's verbosityLevel: 0 is gone. PDFPageRenderer needed no change: pagesToProcess already passes through. strictPagesToProcess, which master still passed, is left out: PdfToPngOptions of the pinned converter has no such option and nothing reads it.
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.
Fixes #88
改动
PDFSplitter改为分批渲染(每批 10 页)并写盘,循环外只保留页面元数据;重试只重试单批/Type的 PDF 被 pdf-lib 少算页数而丢页WorkerOrchestrator新增recoverInterruptedSplits:每次拆页中断都计数(Task.split_interrupt_count,新迁移),累计 3 次就标记为 FAILED 并清理残留图片,不再无限循环;task:retry会把计数清零测试
npm run test:unit:49 个文件,1051 个用例全部通过;npm run test:renderer:283 个用例通过npm run typecheck、eslint:通过已知限制
未验证项