Draft
Conversation
OPFS persistence currently mirrors the live SQLite database directory byte-for-byte. That can copy transient SQLite sidecars such as .ht.sqlite-shm into saved OPFS sites, leaving restore to reopen a database beside stale coordination files. Add a Chromium Playwright regression that creates a stale sidecar before saving a temporary site, verifies the saved OPFS database directory only contains the canonical .ht.sqlite database, reloads the site, and checks SQLite integrity plus WordPress loading. This commit is expected to fail without the snapshot persistence fix.
The OPFS mount previously persisted the live SQLite database and sidecars through normal MEMFS journal replay. That can leave saved sites with stale .ht.sqlite-journal, .ht.sqlite-wal, or .ht.sqlite-shm files next to the database on reload. Add a platform SQLite snapshot primitive that runs VACUUM INTO, validates the result, and lets the worker publish only a coherent .ht.sqlite file into OPFS. Exclude the live database and sidecars from initial sync and journal replay, and wire snapshots into initial persistence, flush, unmount, and debounced DB-write handling. Add focused unit coverage for sidecar filtering, snapshot persistence, and worker snapshot ordering. Include PR.md with the two-commit rollout and verification notes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft PR Description
Summary
This PR fixes OPFS persistence for WordPress sites using SQLite by preventing
transient SQLite sidecar files from being saved alongside the persisted
database.
Previously, OPFS persistence mirrored MEMFS writes at the byte level. That meant
the live SQLite database file and its temporary coordination files could be
copied into OPFS as-is, including files like
.ht.sqlite-shm. Persisting thosesidecars can leave a saved site with a stale SQLite state on reload.
The fix changes OPFS persistence so the live SQLite DB and sidecars are excluded
from normal journal replay and initial MEMFS-to-OPFS sync. Instead, Playground
creates a SQLite-cooperative snapshot with
VACUUM INTO, validates it, andpublishes only the canonical
.ht.sqlitefile into OPFS.Commit Structure
The first commit intentionally adds only the regression test:
Add OPFS SQLite sidecar regression testThat commit is expected to fail in CI against the existing implementation. The
test creates a stale
.ht.sqlite-shmsidecar before saving a temporary site toOPFS, then asserts the saved OPFS database directory does not contain that
sidecar. Without the fix, OPFS contains
.ht.sqlite-shmand the test fails.The second commit adds the implementation and supporting unit coverage:
Persist OPFS SQLite databases via snapshotsWith the implementation in place, the same regression passes because OPFS stores
only the coherent
.ht.sqlitesnapshot.Implementation Details
/internal/shared/snapshot-sqlite.php.PRAGMA wal_checkpoint(TRUNCATE), thenVACUUM INTO.PRAGMA integrity_check..ht.sqlite,.ht.sqlite-journal,.ht.sqlite-wal, and.ht.sqlite-shmfrom OPFS journal replay and initial MEMFS-to-OPFS sync.DirectoryHandleMount.persistSqliteSnapshot()and publishes snapshotsthrough a temp file before replacing
.ht.sqlite.and debounced SQLite DB write handling.
Verification
Regression behavior was verified both ways:
because OPFS contains
.ht.sqlite-shm.Commands run:
Note: this machine needed Playwright Chromium and local browser shared
libraries. The
LD_LIBRARY_PATHprefix points at locally extracted Ubuntubrowser dependency packages used only for this verification environment.