-
Notifications
You must be signed in to change notification settings - Fork 537
Closed
Description
Bug: "Welcome to Hyprnote" session is deleted immediately after creation
Description
When a new user launches the app for the first time (no existing data on disk), initializeStore creates a "Welcome to Hyprnote" session in memory. However, this session is immediately deleted by the session persister's initial load.
Root Cause
Race condition between useInitializeStore and useSessionPersister in persisters.ts:
- React renders, effects fire in order
- Session persister's effect starts the async factory (
useCreatePersistercallsstartAutoPersisting()) — does not block useInitializeStore's effect fires — store has no sessions yet, so it creates the "Welcome to Hyprnote" session in memory- The async
startAutoPersisting()completes — performs its initial load from disk
The initial load goes through multi-table-dir.ts → deletionMarker.markAll():
- For every row in the store that is NOT in the loaded disk data, it marks that row as
undefined(deleted) - Since the welcome session was just created in memory and never saved to disk,
loadAllreturns data without it markAllsees it in the store but not on disk → marks it for deletion- The store applies this, and the session disappears
Relevant Files
apps/desktop/src/store/tinybase/store/initialize.ts— creates the welcome sessionapps/desktop/src/store/tinybase/store/persisters.ts— hooks up persisters and initializationapps/desktop/src/store/tinybase/persister/session/index.ts— async session persister factoryapps/desktop/src/store/tinybase/persister/factories/multi-table-dir.ts— load + deletion marker logicapps/desktop/src/store/tinybase/persister/shared/deletion-marker.ts—markAllimplementation
Fix
Ensure initializeStore runs after the session persister's initial load completes by gating it on the sessionPersister being non-null (returned by useCreatePersister only after the async factory resolves).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Done