E2E smoke: Cannot read properties of undefined (reading 'bulkAdd') on first cold load #159

Closed
opened 2026-08-14 00:59:10 +00:00 by Mark · 1 comment
Owner

Found by: Playwright smoke test (e2e/01-smoke-routes.spec.ts) on 2026-08-13.

Repro: Load any route in a fresh browser context (no prior app data).

Error: Cannot read properties of undefined (reading 'bulkAdd')

Where: First page error captured from src/lib/store.ts (or src/lib/db.ts). Likely path: seedData() calls db.something.bulkAdd(...) on a table that hasn't been declared yet, or a Dexie transaction table reference is captured before the schema upgrade finishes.

Frequency: Always on cold load with no prior IndexedDB schema.

Workaround: Pre-seed via a previous visit that creates the schema, then reload.

Impact: Production users on a fresh install hit a blank dashboard with the seed failing silently. The unit tests pass because they reset mocks per-test and never exercise the real Dexie schema init path.

Suggested fix:

  1. Audit loadAll() / seedData() order of operations - make sure db.<table>.bulkAdd() is only called after Dexie reports the DB as open.
  2. Add a smoke test in e2e/ that asserts pageError events are empty on first cold load.
  3. Consider moving seedData into a db.open().then(...) so we know the schema is committed before reading/writing.

Filed via Playwright smoke harness during e2e/CI setup work.

**Found by:** Playwright smoke test (e2e/01-smoke-routes.spec.ts) on 2026-08-13. **Repro:** Load any route in a fresh browser context (no prior app data). ``` Error: Cannot read properties of undefined (reading 'bulkAdd') ``` **Where:** First page error captured from `src/lib/store.ts` (or `src/lib/db.ts`). Likely path: `seedData()` calls `db.something.bulkAdd(...)` on a table that hasn't been declared yet, or a Dexie transaction table reference is captured before the schema upgrade finishes. **Frequency:** Always on cold load with no prior IndexedDB schema. **Workaround:** Pre-seed via a previous visit that creates the schema, then reload. **Impact:** Production users on a fresh install hit a blank dashboard with the seed failing silently. The unit tests pass because they reset mocks per-test and never exercise the real Dexie schema init path. **Suggested fix:** 1. Audit `loadAll()` / `seedData()` order of operations - make sure `db.<table>.bulkAdd()` is only called after Dexie reports the DB as open. 2. Add a smoke test in `e2e/` that asserts `pageError` events are empty on first cold load. 3. Consider moving `seedData` into a `db.open().then(...)` so we know the schema is committed before reading/writing. Filed via Playwright smoke harness during e2e/CI setup work.
Author
Owner

Closed — unable to reproduce on live device after Dexie fix.

Verified on 2026-09-09 via Android shakedown on a fresh app-debug.apk built from main (commit 9472f685), installed on Kindle G001KT05122500T3 (Android 9, targetSdk=36):

  • adb shell pm clear com.kin.prm to wipe IndexedDB
  • am force-stop + am start
  • Dashboard renders immediately with 4 pre-seeded people (Marcus Chen, Sarah Johnson, David Park, Emma Wilson), goal reminders queued for Mom Johnson / Marcus Chen, and 2 scheduled notifications visible via Capacitor/Console.
  • No Cannot read properties of undefined (reading 'bulkAdd') error in logcat.
  • No Dexie / IndexedDB errors of any kind.

The fix in 7cd6ee7 fix(#159): use Dexie instance for table access in seedData is effective on the live PWA-on-Capacitor build. Original repro path (cold-load IndexedDB schema race in src/lib/store.ts/db.ts) no longer triggers.

Sibling shakedown findings captured separately in #165.

— Closing as resolved. Reopen with a fresh repro if the bulkAdd crash returns on any platform.

**Closed — unable to reproduce on live device after Dexie fix.** Verified on 2026-09-09 via Android shakedown on a fresh `app-debug.apk` built from `main` (commit `9472f685`), installed on Kindle `G001KT05122500T3` (Android 9, `targetSdk=36`): - `adb shell pm clear com.kin.prm` to wipe IndexedDB - `am force-stop` + `am start` - Dashboard renders immediately with 4 pre-seeded people (Marcus Chen, Sarah Johnson, David Park, Emma Wilson), goal reminders queued for Mom Johnson / Marcus Chen, and 2 scheduled notifications visible via Capacitor/Console. - No `Cannot read properties of undefined (reading 'bulkAdd')` error in logcat. - No Dexie / IndexedDB errors of any kind. The fix in `7cd6ee7 fix(#159): use Dexie instance for table access in seedData` is effective on the live PWA-on-Capacitor build. Original repro path (cold-load IndexedDB schema race in `src/lib/store.ts`/`db.ts`) no longer triggers. Sibling shakedown findings captured separately in #165. — Closing as resolved. Reopen with a fresh repro if the bulkAdd crash returns on any platform.
Mark closed this issue 2026-09-09 19:05:09 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Mark/kimi_agent_kin_app_sync#159
No description provided.