Repository navigation
[PHP] Bound pending reads when restoring OPFS sites - #4386
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughOPFS-to-MEMFS restore now acquires capacity before scheduling each read, stops scheduling after a read fails, and waits for outstanding reads to settle before returning. Tests cover bounded enumeration and restore behavior when a read fails. ChangesOPFS restore
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant MountHandler
participant copyOpfsToMemfs
participant OPFS
participant MEMFS
MountHandler->>copyOpfsToMemfs: Start restore
copyOpfsToMemfs->>OPFS: Read files within semaphore capacity
OPFS->>MEMFS: Copy successfully read files
OPFS-->>copyOpfsToMemfs: Return first read error
copyOpfsToMemfs->>OPFS: Wait for outstanding reads to settle
copyOpfsToMemfs-->>MountHandler: Reject with first read error
Merge Risk: ⚪ Minimal · up to The bounded restore and failure-draining paths show no identified merge-blocking issue. Merge after normal checks. 🚥 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 |
Restoring a saved site used to create a pending promise for every entry, even though only 40 reads could run at once. Repeated
Promise.any()calls then attached callbacks to all those pending reads. Large saved sites could exhaust the JavaScript heap.Acquire a slot before creating the read promise. Keep the remaining entries in the directory iterator. If a read fails, drain outstanding reads before returning the error so a retry cannot overlap the previous attempt.
Adds tests for bounded enumeration and failure draining. Does not change OPFS writes, mount tracking, or runtime rotation.
Extracted from #4373. Targets
trunkdirectly and does not depend on the other split PRs.Testing
Save a large Playground locally, reload it, and check that its files restore. Review the tests that hold reads open to check the queue bound and error handling.
Summary by CodeRabbit