@@ -100,7 +100,9 @@ let lastSubscriptionID = 0;
100100// Connections can be made before `Onyx.init`. They would wait for this task before resolving
101101const deferredInitTask = createDeferredTask ( ) ;
102102
103- // Holds a set of collection member IDs which updates will be ignored when using Onyx methods.
103+ // Collection member IDs that Onyx should silently ignore across all operations — reads, writes, cache, and subscriber
104+ // notifications. This is used to filter out keys formed from invalid/default IDs (e.g. "-1", "0",
105+ // "undefined", "null", "NaN") that can appear when an ID variable is accidentally coerced to string.
104106let skippableCollectionMemberIDs = new Set < string > ( ) ;
105107// Holds a set of keys that should always be merged into snapshot entries.
106108let snapshotMergeKeys = new Set < string > ( ) ;
@@ -1119,7 +1121,7 @@ function initializeWithDefaultKeyStates(): Promise<void> {
11191121 . then ( ( pairs ) => {
11201122 const allDataFromStorage : Record < string , unknown > = { } ;
11211123 for ( const [ key , value ] of pairs ) {
1122- // RAM-only keys should never be loaded from storage as they may have stale persisted data
1124+ // RAM-only keys should not be cached from storage as they may have stale persisted data
11231125 // from before the key was migrated to RAM-only.
11241126 if ( isRamOnlyKey ( key ) ) {
11251127 continue ;
@@ -1159,7 +1161,9 @@ function initializeWithDefaultKeyStates(): Promise<void> {
11591161
11601162 // Notify subscribers about default key states so that any subscriber that connected
11611163 // before init (e.g. during module load) receives the merged default values immediately
1162- for ( const [ key , value ] of Object . entries ( merged ?? { } ) ) keyChanged ( key , value ) ;
1164+ for ( const [ key , value ] of Object . entries ( merged ?? { } ) ) {
1165+ keyChanged ( key , value ) ;
1166+ }
11631167 } )
11641168 . catch ( ( error ) => {
11651169 Logger . logAlert ( `Failed to load data from storage during init. The app will boot with default key states only. Error: ${ error } ` ) ;
@@ -1175,7 +1179,9 @@ function initializeWithDefaultKeyStates(): Promise<void> {
11751179
11761180 // Notify subscribers about default key states so that any subscriber that connected
11771181 // before init (e.g. during module load) receives the merged default values immediately
1178- for ( const [ key , value ] of Object . entries ( defaultKeyStates ) ) keyChanged ( key , value ) ;
1182+ for ( const [ key , value ] of Object . entries ( defaultKeyStates ) ) {
1183+ keyChanged ( key , value ) ;
1184+ }
11791185 } ) ;
11801186}
11811187
0 commit comments