Skip to content

fix: SQLite write-ahead log, and one session per seeded account in e2e - #16

Merged
bvdaakster merged 1 commit into
mainfrom
fix/e2e-flakes
Nov 28, 2026
Merged

bvdaakster merged 1 commit into
mainfrom
fix/e2e-flakes

Conversation

@bvdaakster

Copy link
Copy Markdown
Contributor

Two e2e specs (notifications, mailing) failed now and then when the suite ran locally with 7 workers. There were two separate causes, and neither was specific to those specs.

1. Synchronous SQLite writes stall the server

The SQLite client runs every statement synchronously on the server's only thread. In SQLite's default rollback-journal mode each write syncs to disk several times, so whenever the disk is busy nothing is answered until the write returns. Measured with an event-loop monitor in the server during a 7-worker run: the loop stood still for up to 5.4 s while the process used about 25% CPU. Any assertion waiting on a server action then hits Playwright's 5 s limit, in whichever test happens to be waiting.

That also explains the notifications report ("unread was 1 after Mark all as read"): after unfollowing Studio news a new member has exactly one unread notification, so the page had simply not refreshed yet. No notification from a parallel test was involved.

Change: the database uses the write-ahead log (wal in sqliteAdapter), which syncs once per write, with the same durability as before. SQLITE_SYNCHRONOUS=NORMAL turns the per-write sync off (safe from corruption; a power cut can lose the last writes). The e2e server sets it, because its database is thrown away.

To start over locally, delete kiln.db* now (the database plus kiln.db-wal and kiln.db-shm); README and .env.example say so.

2. Parallel logins of one account sign each other out

Payload's login reads the user, checks the password and writes the whole session list back. Logins of one account that overlap therefore lose sessions: 6 concurrent logins of the seeded admin leave 1 valid session (6 of 6 when done one after the other). The seeded accounts are shared by tests in different workers, each of which logged in itself, so a test could find itself signed out halfway ("Run the studio digest now" button missing, flag API returning no docs).

Change: a Playwright global setup logs each seeded account in once, in sequence, and signIn, signInToAdmin and adminApi in tests/helpers/e2e.ts reuse those sessions. One test still goes through the login form (signInWithForm, site spec).

Numbers (full suite, --workers=7, same machine, other jobs running on it)

runs with failures wall time longest event-loop stall
before 8 of 9 1.0 to 2.2 min 4.0 to 5.4 s
write-ahead log only, sync on every write 2 of 3 (all from cause 2) 1.1 to 1.2 min 1.5 to 2.1 s
this PR 0 of 12 48 to 54 s under 1 s

playwright test notifications mailing --repeat-each=30 --workers=7 with this PR: the two reported tests pass 30 of 30, as do four others. "a member sees the bell count…" fails under --repeat-each (21 of 30) because it marks one of the seeded member's notifications as read each time and repeats run in parallel on the same account; it cannot be repeated on one database and passes in every normal run.

No timeout or retry was changed.

🤖 Generated with Claude Code

https://claude.ai/code/session_0122PV8TJ7ELGdAX7H2hdrRU

Two separate causes made the e2e suite fail now and then with 7 local workers.

The SQLite client runs every statement synchronously on the server's only
thread. In the default rollback-journal mode each write syncs to disk several
times, so while the disk was busy the event loop stood still for up to 5
seconds and any assertion waiting on a server action timed out. The database
now uses the write-ahead log (one sync per write), and SQLITE_SYNCHRONOUS=NORMAL
turns the per-write sync off; the e2e server sets it for its throwaway database.

Payload's login reads the user, checks the password and writes the whole
session list back, so logins of one account that overlap sign each other out:
6 concurrent admin logins leave 1 valid session. The seeded accounts are shared
by parallel tests, which each logged in for themselves. A global setup now logs
each seeded account in once, and the sign-in helpers reuse those sessions.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0122PV8TJ7ELGdAX7H2hdrRU
@claude

claude Bot commented Nov 28, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@bvdaakster
bvdaakster merged commit 2f994ba into main Nov 28, 2026
3 checks passed
@bvdaakster
bvdaakster deleted the fix/e2e-flakes branch November 28, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant