Repository navigation
[PHP] Retain current OPFS mounts across PHP runtime rotation - #4389
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughThe change updates PHP mount teardown, OPFS writer cleanup, and worker endpoint mount tracking. Tests cover handler replacement, write and cleanup failures, failed mount retries, and runtime rotation. ChangesOPFS mount lifecycle
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant PlaygroundWorkerEndpoint
participant PHP
participant OPFSMountHandler
PlaygroundWorkerEndpoint->>PHP: Pass wrapped handler to PHP.mount
PHP->>PlaygroundWorkerEndpoint: Invoke wrapped handler during mount
PlaygroundWorkerEndpoint->>OPFSMountHandler: Run handler after clearing mount tracking
alt Handler succeeds
OPFSMountHandler-->>PlaygroundWorkerEndpoint: Return from handler
PlaygroundWorkerEndpoint->>PlaygroundWorkerEndpoint: Track replacement mount
else Handler fails
OPFSMountHandler-->>PlaygroundWorkerEndpoint: Throw mount error
PlaygroundWorkerEndpoint->>PlaygroundWorkerEndpoint: Remove stored unmount callback
end
Merge Risk: ⚪ Minimal · up to The mount lifecycle change is mergeable after normal checks; no concrete remaining failure was identified. 🚥 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 |
Avoid calling an already-unmounted mount's cleanup again after PHP replaces its runtime.
Background
For a storage mount at
/wordpress:unmount()function.unmount(). Previously, this called the old mount's cleanup a second time. It could leave the current mount active while removing it from PHP's mount tracking.This change
The saved
unmount()now looks up the current mount and runs its cleanup. It follows replacements made with the same mount handler. If a different handler later mounts something at the same path, the saved function leaves that mount alone. After a successful unmount, further calls do nothing.Explicit OPFS flushes also use the current mount's journal after runtime replacement. The replacement journal is registered only after its initial copy succeeds, so a failed setup leaves another save possible. Failed OPFS writes preserve the original error even if stream cleanup also fails.
Includes tests for runtime replacement, repeated unmount calls, a different mount at the same path, setup failures, and quota errors.
PR 5 extracted from #4373. Targets
trunkdirectly; no dependency on the other split PRs.Testing
Save a Playground locally, replace its PHP runtime, edit a file, flush, and reopen it. Check that the edit persists. Call the saved
unmount()twice and check that cleanup runs only for the current mount, once.Summary by CodeRabbit