-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Description
In the restore saga, the code reads a legacy pushNotification item from AsyncStorage and then attempts to remove it. However, the inner const pushNotification declaration shadows the outer variable. Since AsyncStorage.removeItem() returns undefined (not the old value), JSON.parse(undefined) throws a SyntaxError. This is caught by the catch block which dispatches appStart({ root: ROOT_OUTSIDE }), forcing the user to the welcome/login screen and silently dropping the notification.
Buggy code:
const pushNotification = yield call(AsyncStorage.getItem, 'pushNotification');
if (pushNotification) {
const pushNotification = yield call(AsyncStorage.removeItem, 'pushNotification'); // ← shadows outer variable, gets undefined
yield call(deepLinkingClickCallPush, JSON.parse(pushNotification)); // ← JSON.parse(undefined) → SyntaxError
}Environment Information:
- Rocket.Chat Server Version: Any
- Rocket.Chat App Version: Latest (
developbranch) - Device Name: Any (iOS / Android)
- OS Version: Any
Steps to reproduce:
- Temporarily add this line before line 57 in
app/sagas/init.js:yield call(AsyncStorage.setItem, 'pushNotification', JSON.stringify({ rid: 'GENERAL', name: 'general' }));
- Build and launch the app.
- Observe the crash behavior.
Expected behavior:
- The app should read the stored push notification, remove it from AsyncStorage, parse it correctly, and deep-link to the relevant room/channel.
- The user should remain logged in and see the notification content.
Actual behavior:
AsyncStorage.removeItem()returnsundefined(it does not return the deleted value).- The inner
const pushNotificationshadows the outer variable, so it becomesundefined. JSON.parse(undefined)throws aSyntaxError.- The
catchblock on line 62-65 catches the error and dispatchesappStart({ root: ROOT_OUTSIDE }). - The user is forcibly kicked to the welcome/login screen.
- The push notification they tapped on is silently lost.
Reactions are currently unavailable