Repository navigation
fix(viewer): suppress stale PDF render publication - #323
seonghobae wants to merge 13 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughPDF 인라인 렌더링이 ChangesPDF 렌더링 취소 처리
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Polling
participant Viewer
participant PDFjs
participant PreviewDOM
Polling->>Viewer: PDF 렌더링 요청 및 AbortSignal 전달
Viewer->>PDFjs: PDF 로드, 페이지 조회, 캔버스 렌더링
Polling->>Viewer: 렌더링 후 취소 상태 확인
Viewer-->>Polling: false 반환
Polling-->>PreviewDOM: 링크와 완료 상태를 게시하지 않음
Possibly related issues
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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 |
|
@opencode-agent @cwl-noema-review Please independently review exact current head |
|
@coderabbitai review |
|
@coderabbitai review Please review exact current head |
|
🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
head_sha="$(git rev-parse HEAD)"
base_sha="83ec6f7fe2b04bdcd28bf98ec350e41e55730a18"
expected_head="79689f928d8552c65dbdecf85ed45e2e9a6f1109"
printf 'HEAD=%s\nEXPECTED_HEAD=%s\nBASE=%s\n' "$head_sha" "$expected_head" "$base_sha"
git diff --check "${base_sha}..${expected_head}"
git diff --stat "${base_sha}..${expected_head}"
git diff --name-status "${base_sha}..${expected_head}"
printf '\n== Locate candidate files ==\n'
fd -HI '^(viewer\.js|test_viewer_render_cancellation\.py)$' . \
-E .git -E node_modules -E dist -E build || true
printf '\n== JavaScript structure ==\n'
viewer_file="$(fd -HI '^viewer\.js$' . -E .git -E node_modules -E dist -E build | head -n 1)"
if [ -n "$viewer_file" ]; then
ast-grep outline "$viewer_file" --items all --type function --match 'renderPdfInline|poll' --view expanded || true
printf '\n== Relevant source occurrences ==\n'
rg -n -C 16 -P '\b(renderPdfInline|poll)\s*\(|\.render\s*\(|appendChild\s*\(|textContent\s*=|innerHTML\s*=|ready|preview|abortSignal|aborted)\b' "$viewer_file"
fi
printf '\n== Exact source diff ==\n'
git diff --find-renames --find-copies --unified=80 "${base_sha}..${expected_head}" -- \
':(glob)**/viewer.js' \
':(glob)**/test_viewer_render_cancellation.py'Length of output: 2440 🏁 Script executed: #!/bin/bash
set -euo pipefail
base_sha="83ec6f7fe2b04bdcd28bf98ec350e41e55730a18"
head_sha="79689f928d8552c65dbdecf85ed45e2e9a6f1109"
viewer="src/main/resources/static/assets/viewer/viewer.js"
test_file="scripts/test_viewer_render_cancellation.py"
printf '%s\n' '== viewer.js: imports, state, and renderPdfInline =='
sed -n '1,235p' "$viewer" | cat -n
printf '%s\n' '== viewer.js: poll and subsequent state publication =='
sed -n '236,430p' "$viewer" | cat -n
printf '%s\n' '== Regression test =='
cat -n "$test_file"
printf '%s\n' '== Exact diff =='
git diff --check "${base_sha}..${head_sha}"
git diff --unified=60 "${base_sha}..${head_sha}" -- "$viewer" "$test_file"
printf '%s\n' '== All DOM/state publication calls in viewer.js =='
rg -n -C 5 -e 'appendChild\s*\(' -e 'replaceChildren\s*\(' -e '\.textContent\s*=' \
-e '\.innerHTML\s*=' -e 'setAttribute\s*\(' -e 'updateStatus\s*\(' \
-e 'renderPdfInline\s*\(' -e 'await\s+' "$viewer"Length of output: 42342
No findings.
The Node regression holds the PDF.js render promise, aborts the operation, completes the old render, and verifies zero preview children. This test covers stale canvas and metadata publication. The change does not modify the separate signed external-artifact path or
|
d7a3342 to
4ea2cce
Compare
|
@opencode-agent @cwl-noema-review Please independently review exact current head |
Pull request was converted to draft
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
scripts/test_viewer_render_cancellation.py (1)
151-156: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win마이크로태스크 개수에 의존하면 검증 대상 경로가 달라집니다.
renderPdfInline은 abort 전에getPdfJsModule(),loadingTask.promise,pdfDocument.getPage(1)을 순차로 await합니다.getPage가async함수이므로 필요한 마이크로태스크 수가 두 번을 초과할 수 있습니다. 이 경우 abort는 Line 160의getPage이후 확인에서 감지됩니다. assert는 통과하지만 렌더 완료 후 게시 억제 경로(viewer.js Line 183-186)는 검증되지 않습니다.
render()호출 시점을 관측 가능한 신호로 만들고 그 신호를 await한 후 abort하십시오. 그러면 검증 대상 경로가 결정됩니다.♻️ 제안 수정
+ let renderStarted; + const renderStartedPromise = new Promise(resolve => { + renderStarted = resolve; + }); let resolveRender; const renderPromise = new Promise(resolve => { resolveRender = resolve; }); const pdfDocument = { numPages: 1, async getPage() { return { getViewport({ scale }) { return { width: 100 * scale, height: 200 * scale }; }, render() { + renderStarted(); return { promise: renderPromise }; }, }; }, async destroy() {}, };- // Let getDocument/getPage reach the deliberately unresolved render promise. - await Promise.resolve(); - await Promise.resolve(); + // Wait until page.render() actually starts, then supersede the operation. + await renderStartedPromise; controller.abort(); resolveRender(); - await rendering; + assert.equal(await rendering, false, "an aborted render must report failure");🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@scripts/test_viewer_render_cancellation.py` around lines 151 - 156, Update the cancellation test around renderPdfInline so it observes a signal when render() is invoked, awaits that signal, and only then calls controller.abort() and resolveRender(). Remove the fixed double Promise.resolve() scheduling, ensuring the test deterministically exercises the post-render publication-suppression path rather than relying on getDocument/getPage microtask timing.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@scripts/test_viewer_render_cancellation.py`:
- Around line 171-186: Convert the module-level
test_superseded_pdf_render_does_not_publish function into a method on a
unittest.TestCase subclass, preserving its existing Node.js harness execution
and assertions. Ensure the module imports unittest and the resulting test class
and method are discoverable by python3 -m unittest discover -s scripts.
---
Nitpick comments:
In `@scripts/test_viewer_render_cancellation.py`:
- Around line 151-156: Update the cancellation test around renderPdfInline so it
observes a signal when render() is invoked, awaits that signal, and only then
calls controller.abort() and resolveRender(). Remove the fixed double
Promise.resolve() scheduling, ensuring the test deterministically exercises the
post-render publication-suppression path rather than relying on
getDocument/getPage microtask timing.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: c609e833-b01a-4e9c-a495-1ef3b4e6b369
📒 Files selected for processing (2)
scripts/test_viewer_render_cancellation.pysrc/main/resources/static/assets/viewer/viewer.js
|
Already queued @cwl-noema-review and @opencode-agent on this exact request for PR #323 at head |
|
Already queued @cwl-noema-review and @opencode-agent on this exact request for PR #323 at head |
|
Already queued @cwl-noema-review and @opencode-agent on this exact request for PR #323 at head |
|
Already queued @cwl-noema-review and @opencode-agent on this exact request for PR #323 at head |
|
Already queued @cwl-noema-review and @opencode-agent on this exact request for PR #323 at head |
|
Already queued @cwl-noema-review and @opencode-agent on this exact request for PR #323 at head |
|
Already queued @cwl-noema-review and @opencode-agent on this exact request for PR #323 at head |
|
Already queued @cwl-noema-review and @opencode-agent on this exact request for PR #323 at head |
|
Already queued @cwl-noema-review and @opencode-agent on this exact request for PR #323 at head |
|
Already queued @cwl-noema-review and @opencode-agent on this exact request for PR #323 at head |
|
Already queued @cwl-noema-review and @opencode-agent on this exact request for PR #323 at head |
|
Already queued @cwl-noema-review and @opencode-agent on this exact request for PR #323 at head |
|
Already queued @cwl-noema-review and @opencode-agent on this exact request for PR #323 at head |
1 similar comment
|
Already queued @cwl-noema-review and @opencode-agent on this exact request for PR #323 at head |
|
Admission correction — exact current head |
Ready admission restored on the unchanged exact headImmediately before the single Draft → Ready transition, exact head
Ready is review admission only. Missing CodeQL evidence and approval continue to block merge, but they are not Draft reasons under current authority. The state was toggled exactly once; no manual rerun, no-op commit, synthetic event/status, bypass, or predecessor evidence transfer was used. |
Current authority — exact head
|
Causal-owner correction — exact head unchangedThe shared Jackson repair is owned by canonical clearfolio #503 at exact head |
Objective
Prevent a superseded PDF.js render from publishing stale canvas, metadata, preview links, or terminal
Ready.state after a newer viewer operation starts.Exact current-head evidence
main@06633a25109c62e24a7015ae04fb9f6e0a246f7e;2fc4ec4993dea5a7beadef8a2e87433201d4956a;viewer.jsand the executable Node/unittest regression only;36932467991: success;36932467923: success;36932467956: failure with substantive Trivy findings;36932468028: success;36932467944: queued;Predecessor-head runs
32146001890,32146001916,32146001814, and32146001700are historical only and do not satisfy this head's merge gate.Corrective history
An unrelated formatting-only change intended for clearfolio #454 was mistakenly committed to this branch as
d7a5e2c4848a02800c6784b67787a97cbca8b070. It was detected immediately and reversed without Force Push by ordinary revert commit2fc4ec4993dea5a7beadef8a2e87433201d4956a. The restored test-file blob is88503b4864ee8010728f019497ef9ca03ad3d991; the effective PR file delta remains the original two viewer paths. Because history changed, all predecessor exact-head evidence was invalidated and fresh checks were required.Security blocker and causal owner
Security run
36932467956, job110604972561, checked out this exact head and emitted SARIF successfully. Trivy reported five fixable findings atpom.xml:151forcom.fasterxml.jackson.core:jackson-databind:CVE-2026-68497,CVE-2026-91776,CVE-2026-91777;CVE-2026-19032,CVE-2026-83557.This viewer delta did not introduce the dependency, but the exact candidate includes it. Therefore the finding is not waived or treated as a stale event. The canonical common dependency repair is clearfolio #503 at exact head
bf121dffff24e771739f50b9e2cc7961459670a2. It must integrate at the protected shared base with fresh security evidence, and this branch must then be reconciled non-destructively before returning to Ready.Rendering contract
The runtime checks cancellation around PDF.js module loading, document loading, page acquisition, render completion, and every subsequent DOM/publication boundary. The regression is discoverable through
python3 -m unittest discover -s scripts, waits for an observablerender()start rather than a guessed microtask count, supersedes the operation, and proves the stale canvas, metadata, links, and terminal status cannot publish.Scope boundary
This slice suppresses stale publication. It does not itself actively invoke
RenderTask.cancel()or destroy an unresolved loading task; child #445 owns that resource-cancellation delta and must be rebuilt on protected main after this parent integrates. Issue #322 remains open for rapid multi-generation/error-state coverage, signed-token lifecycle parity, terminal focus ownership, and unhandled-rejection proof.Merge gate
HOLD merge. Keep the valid viewer delta and corrective history intact. Remain Draft until the shared
jackson-databindvulnerability repair reaches the protected base and this branch is non-force reconciled, then require fresh exact-head CI, Security, SAST, fuzz, CodeQL/central terminal evidence, zero valid unresolved findings, and a qualifying independent non-author approval. No bypass, Force Push, synthetic evidence, blind rerun, or predecessor-evidence transfer is authorized.