fix(viewer): actively cancel superseded PDF.js work - #347
Draft
seonghobae wants to merge 3 commits into
Draft
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Objective
Advance the remaining resource-cancellation acceptance in issue #322 without moving parent #323's exact reviewed/verified identity. A superseded viewer operation must not only suppress stale DOM publication; where PDF.js exposes cancellation/destruction APIs, it must actively cancel the current
RenderTaskand destroy an in-flightPDFDocumentLoadingTask.Fresh exact stack state — 2026-08-10
29438e42327a1bd5b888422fbfde713f7fca9b5a;8914580339c644f2cfdfef6a1634dfd5cff53693;main55d7ae8647208e301f282350f076eeddaba61d11;viewer.jsand this run did not move the parent exact identity;31406253421: success;31406253440: success;Because this stacked PR targets the parent branch rather than
main, no main-targeted Security Scan/SAST result is synthesized as passing evidence. After #323 integrates and this child is rebuilt/reconciled onto the new exact protected main, all base-sensitive security/review evidence must be regenerated before final merge.Test-first / RCA evidence
RED
Test-only head
5e7cbd2c6a868332ea8c1da371ce73cc46253d5dadded a real Node runtime regression around PDF.js resources before production changes. Exact-head CI31405521868failed Buyer-readiness scripts exactly at the first intended boundary: aborting a viewer operation while the first-pageRenderTask.promisewas held pending producedcancelCalls = 0, proving parent #323 suppressed stale publication but did not actively cancel the renderer.First GREEN attempt exposed a harness race
Production head
36bb461ed7d02febea446d3a1bce3c2fff163b99added active cancellation/destruction, but exact-head script CI still reportedcancelCalls = 0. RCA showed the regression used a fixed count of resolved microtasks before aborting; that did not provepage.render()had actually started in the Node VM. The failure was therefore timing-sensitive test synchronization, not proof that the new cancel listener was absent. The test was corrected to expose explicitrenderStarted/loadingStartedsynchronization boundaries instead of sleeping/yielding an assumed number of microtasks.GREEN
Current
renderPdfInline(...)now:RenderTaskand callscancel()exactly once when the operation aborts;PDFDocumentLoadingTaskon abort when PDF.js exposesdestroy();finallyand still destroys a resolvedPDFDocumentProxy.The synchronized Node regression proves both active render-task cancellation and loading-task destruction. The unchanged exact head is GREEN across buyer-readiness runtime scripts, full Maven verify/coverage/Javadocs, synthetic parent-merge compatibility and fuzz.
Scope / remaining issue contract
This child does not duplicate #323 stale-publication suppression, issue #317 identity/bootstrap work, #264
demo.js/dom-utils.js, signed-token authority, terminal focus ownership, or rapid three-generation/error-state coverage. Signed-token mode still invokesrenderPdfInlinewithout a generation signal; parity remains open under issue #322.Do not close issue #322 when this child eventually integrates. Remaining acceptance includes rapid multi-generation/error-state coverage, signed-token lifecycle parity, terminal status/focus ownership, and proof that cancellation cannot surface an unhandled rejection in the supported PDF.js runtime.
Dependency gate
Keep this PR Draft while parent #323 is open. Merging the child into the parent branch would move #323's exact reviewed/verified identity and collapse two independently reviewable semantics. After #323 reaches protected main, rebuild/reconcile this unique delta onto the new exact protected base, regenerate all main-targeted CI/security/review evidence, and only then move the child toward final merge.