Repository navigation
fix(workers): prevent PDF cancellation from aborting Node - #150752
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 17, 2026, 6:31 AM ET / 10:31 UTC (Revision 4). ClawSweeper reviewWhat this changesThe PR makes PDF cancellation wait for bounded PNG compression before stopping its worker, adds a documented worker-control API, and updates regression coverage and tooling imports. Merge readiness✅ Ready for maintainer review The fix remains necessary and has no blocking correctness findings. The recorded maintainer disposition resolves the previous review’s tradeoff questions; no additional review action is required. Priority: P1 Review scores
Verification
How this fits togetherThe document-extraction plugin sends PDFs to a reusable worker and returns extracted text or page images. The shared worker pool owns cancellation, worker termination, and capacity release. flowchart TD
A[PDF extraction request] --> B[Shared worker pool]
B --> C[Extract text and render pages]
C --> D[Bounded PNG compression]
E[Cancellation or deadline] --> F[Close native admission]
F --> D
D --> G[Join worker exit]
G --> H[Release capacity and settle cancellation]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +176, Tests +288, Docs +15, Other +2. Total +481 across 13 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Retain the documented, narrowly bounded PNG fence and immediate cancellation elsewhere, with archived-history compression handled separately. Do we have a high-confidence way to reproduce the issue? Yes: the inspected production-pool fixture targets cancellation during real zlib initialization, and the submitted Node 24.19.0 evidence reports the original abort. This read-only review did not rerun it. Is this the best way to solve the issue? Yes: the existing pool owns safe retirement, while the PDF plugin fences only compression; the documented deadline and SDK tradeoffs have been explicitly accepted. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3bbe54346069. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
cb6a70d to
e915d8a
Compare
Fence bounded native operations before worker retirement and keep PDF rendering immediately cancellable. Hold admission until native completion and worker exit, and cover cancellation, deadlines, close, and unexpected exit. Observed in CI run 35193123721, job 105110271154. Linux Node 24.19 reproduces SIGABRT before the fix and exits cleanly after it; 20 PDF and extension-stripe repetitions pass. The required macOS stripe remains blocked by a no-output watchdog failure, so publication is withheld.
e915d8a to
a2f7a59
Compare
|
Merged via squash.
|
Restore the configured pnpm store before activation so warm CI jobs reuse the pinned wrapper and native executable archives without another registry download. Verify private archive copies with the existing SHA-512 pins, retain image and registry fallback, and preserve bootstrap archives during dependency repair. The existing warmer remains the cache publisher. Update isolated archive fixtures, acceptance guards, and CI documentation for the cache-first bootstrap. Store v2 and dependency v4 entries reseed once; application behavior and user data are unchanged. Validation: exact-head CI run 35217823757 is green with no pending checks; retained hosted cold/warm proof records zero archive downloads on the warm run. The package-acceptance suite passed 558 tests on three full runs, followed by 23 final focused tests. The campaign review and exact-head ClawSweeper review report no actionable correctness findings. Related: #150752, #150725.
…50752) Fix Node aborting when PDF extraction is cancelled during native PNG compression. Related: openclaw#150494; reproduced in CI run 35193123721, job 105110271154. The shared worker pool atomically closes native-section admission and waits for active native work before terminating the worker. PDF extraction fences only pixel- and dimension-bounded PNG encoding, checks cancellation between pages, and keeps rendering immediately cancellable. Admission and execution capacity remain reserved until worker exit. The existing worker SDK exports and handlers stay compatible, and the two extracted pool modules are included in the native wrapper inventory. Cancellation can wait beyond its deadline if a fenced native operation gets stuck; the bounded-operation SDK contract documents this accepted tradeoff. Archived-history zstd cancellation remains a separate follow-up. No configuration, dependency, Node-version, or persistence changes are required. Validation: Linux Node 24.19.0 reproduced SIGABRT before the fix and clean abort, timeout, close, and unexpected-exit cases afterward. The author recorded 51 pool tests, 23 PDF tests, and 20 serial PDF and extension-stripe repetitions passing. Hosted exact-head CI run 35208006886 is green; local full-stripe and provisioning timing limitations are documented in the PR. Codex autoreview and the exact-head ClawSweeper review found no actionable P0/P1 correctness findings.
Restore the configured pnpm store before activation so warm CI jobs reuse the pinned wrapper and native executable archives without another registry download. Verify private archive copies with the existing SHA-512 pins, retain image and registry fallback, and preserve bootstrap archives during dependency repair. The existing warmer remains the cache publisher. Update isolated archive fixtures, acceptance guards, and CI documentation for the cache-first bootstrap. Store v2 and dependency v4 entries reseed once; application behavior and user data are unchanged. Validation: exact-head CI run 35217823757 is green with no pending checks; retained hosted cold/warm proof records zero archive downloads on the warm run. The package-acceptance suite passed 558 tests on three full runs, followed by 23 final focused tests. The campaign review and exact-head ClawSweeper review report no actionable correctness findings. Related: openclaw#150752, openclaw#150725.
Related: #150494 — observed in CI run 35193123721, job 105110271154.
What Problem This Solves
Fixes Node aborting when PDF extraction is cancelled while PNG compression is initializing a native zlib handle. The failing stripe printed Google Meet export results immediately before the abort, but the reproduced producer was the PDF extraction worker.
User Impact
Cancelling PDF extraction returns the cancellation result and permits subsequent documents to run. PDF rendering stays immediately cancellable; cancellation during PNG encoding waits for that bounded operation and worker exit. No configuration, dependency, Node-version, or persistence changes are required.
Why This Change Was Made
The pool closes native-section admission atomically and waits for active sections before terminating a worker. Workers cannot enter another native section after cancellation; PDF extraction checks cancellation between pages, and admission capacity stays reserved until worker exit. Only PNG encoding is fenced. The worker-side server is extracted into a sibling module to retain the existing line cap and public exports.
This PR also touches the native wrapper component inventory,
scripts/pr-lib/wrapper-components.txt: the pool eagerly importsworker-task-native-sections.tsand reexportsworker-task-server.ts, so both modules must be materialized with the wrapper. Exactly those two entries were added in lexical order.The existing task deadline requests cancellation; it cannot safely force termination through a stuck native call. Native sections must therefore contain bounded operations, not rendering, network waits, or an entire document.
Named follow-up — Archived-history zstd cancellation fence:
src/config/sessions/archive-compression.ts:70synchronously decompresses archive data reached fromsrc/gateway/session-transcript-archive-reader.ts:223and the history-page worker atsrc/config/sessions/session-transcript.worker.ts:189. The reader/materialization layers do not carry task control, and the codec API is synchronous. A separate change must propagate task control to the codec, preserve the synchronous reader contract, and add its regression proof. Fencing the entire history read would also defer cancellation during unrelated I/O.Evidence
close before init, and the fatalHandleScopeerror. The repaired abort, timeout, close, and unexpected-worker-exit cases all exit 0. Focused pool validation: 51 tests passed.OPENCLAW_VITEST_MAX_WORKERS=2 node scripts/run-vitest.mjs run --config test/vitest/vitest.extensions.config.ts --shard=2/6.tbx_01m2q5s8ddshbeqr8a70h2a7bb; command result exit 0, lease stopped and verified completed. The provider command result is the proof; external lease cleanup can cancel the enclosing Actions workflow.Declaration input escapes checkout; directoxlint --tsconfig test/tsconfig/tsconfig.extensions.test.jsoncaught the temporaryno-explicit-anycanary (exit 1), then all four real extension files passed (exit 0). The canary was removed, and all eight remaining guards passed.--mode branch --base origin/main --max-priority P1, scoped-clean, no actionable P0/P1 findings. Artifact:l555-branch-review.mdwith status artifactl555-branch-review-status.json.test/scripts/pr-worktree-provision.test.ts:378took 139.97 seconds against a 120-second test budget on host load 55–123. The maintainer classified this as host overload and directed publication with hosted CI as proof. No rerun, timeout increase, or test change; the remaining local wrapper suites and another changed-check run were not run.l555-inventory-review.md, statusl555-inventory-review-status.json.a2f7a594fdfa5cba7337570b1de59f0365c571ec, rebased onto main9ee5c26f4080b4f63243897c904243802efbc3bf. Verified that main contains the fix(runtime): close Bun watcher and harness gaps #150655 fix at5764fa493344c0a041e0bc8319c07585d649b18e. Both lane commits are unchanged (=) ingit range-diff; no conflict resolution or semantic changes.pnpm install --frozen-lockfilepassed in 18.2 seconds. The worktree remained clean.pull_requestCI GREEN: run 35208006886 ata2f7a594fdfa5cba7337570b1de59f0365c571ec. Native watcher exited 0 withgithub_rollup=SUCCESS,pending=0, andGREEN. The previous red run was not rerun. Ready for maintainer landing; not merged.Maintainer disposition of ClawSweeper feedback
Reviewed ClawSweeper revision 3 on the exact head above. It reports no correctness findings. Both merge-risk items are accepted under the scoped landing instruction:
No Rank-up code changes are outstanding. The archived-history zstd fence remains the named separate follow-up above.