issue: https://linear.app/comm/issue/ENG-5905/uncaught-typeerror-cannot-read-properties-of-undefined-reading
The following error was showing up on some peoples consoles:
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'updatesCurrentAsOf') at U7 (prod.4ff39ebc9fcd.build.js:2:4648139) at prod.4ff39ebc9fcd.build.js:2:4683479 at prod.4ff39ebc9fcd.build.js:2:4682129 at y (prod.4ff39ebc9fcd.build.js:2:1767761) at prod.4ff39ebc9fcd.build.js:2:4683981 at Object.dispatch (prod.4ff39ebc9fcd.build.js:2:2405643) at WebSocket.<anonymous> (prod.4ff39ebc9fcd.build.js:2:4669607)
The reason was that setNewSessionActionType was being dispatched from the Socket without keyserverID in payload. The keyserver id is required, but dispatch is not typed very well, so flow didn't catch it. This was causing a new keyserver to be added to the keyserver store by the keyserver reducer - a keyserver with id undefined. This keyserver was not previously present in the store, so state.keyserverStore.keyserverInfos[keyserverID].updatesCurrentAsOf in baseReducer would throw.
So the fist thing that has to be done, is fixing the payload.
Secondly, we have an action that can add a keyserver to the store, and this would also result in this error being thrown. But when addKeyserverActionType is dispatched we don't need to update currentAsOf or updatesCurrentAsOf, so we will just if this out (change in master-reducer.js line 87)
Thirdly, we should protect ourselfes from this error in case someone adds some code that can add a keyserver and doesn't update this code (change in master-reducer.js line 109).