Skip to content

Fix stale OPFS exports after pooled PHP requests - #4240

Draft
ashfame wants to merge 4 commits into
trunkfrom
agent/fix-opfs-request-flush-export-barrier
Draft

Fix stale OPFS exports after pooled PHP requests#4240
ashfame wants to merge 4 commits into
trunkfrom
agent/fix-opfs-request-flush-export-barrier

Conversation

@ashfame

@ashfame ashfame commented Aug 3, 2026

Copy link
Copy Markdown
Member

What

Fix saved-site ZIP exports that could omit recent writes made by a pooled PHP instance.

This PR deliberately preserves the investigation sequence in separate commits: regression coverage first, the request-end trigger fix second, and the OPFS export durability barrier third.

Root cause

Secondary PHP instances write through PROXYFS into the primary PHP instance MEMFS, so the primary OPFS journal captures their file operations. However, request.end is emitted on the secondary PHP instance while the mounted journal listens on the primary instance. A pooled request could therefore finish with captured operations still queued in memory, and direct saved-site export would traverse stale OPFS contents. Explicit saving only appeared to repair the archive because another lifecycle operation happened to trigger the pending flush.

Direct export also lacked an awaited boundary around asynchronous journal replay. Even with the missing trigger fixed, a ZIP traversal could race a flush that had already been scheduled.

Commit and CI sequence

  1. eba38e26d added the pooled-PHP browser regression, and b4e0945a6 corrected its marker path to a guaranteed existing directory. The corrected regression proves the marker exists in live MEMFS but remains absent from OPFS: expected CI failure.
  2. 4aa613f5a flushes every active OPFS journal when a secondary PHP request ends. The same Chromium shard then passes: trigger-fix CI success.
  3. 384574945 adds a per-site, origin-wide Web Locks boundary. Journal replay holds an exclusive lock; direct ZIP export holds the matching shared lock, so export waits for earlier writes and traverses a stable snapshot. The actual OPFS directory path identifies the lock, including legacy saved-site directories.

Tests

  • npm exec -- nx run-many -t typecheck -p php-wasm-web playground-remote playground-website --parallel=3
  • npm exec -- nx run-many -t test -p php-wasm-web playground-remote playground-website --parallel=3 (468 tests)
  • npm exec -- nx run-many -t lint -p php-wasm-web playground-remote playground-website --parallel=3
  • Focused Chromium pooled-PHP OPFS regression (1 test)
  • Final CI run passed, including the regression-bearing Chromium shard.

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