Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugnsnag error: Cannot read property 'syncEndTime' of null #1178

Closed
1t5j0y opened this issue Nov 9, 2023 · 3 comments
Closed

Bugnsnag error: Cannot read property 'syncEndTime' of null #1178

1t5j0y opened this issue Nov 9, 2023 · 3 comments
Assignees

Comments

@1t5j0y
Copy link
Contributor

1t5j0y commented Nov 9, 2023

https://app.bugsnag.com/samanvay-research-and-development-foundation/avni-client/errors/654b8b8ced7ec300080c5707

TypeError Fatal error: Cannot read property 'syncEndTime' of null 
    /home/circleci/avni-client/packages/openchs-android/src/task/Sync.js:75:57 wasLastCompletedSyncDoneMoreThanHalfAnHourAgo
    /home/circleci/avni-client/packages/openchs-android/src/task/Sync.js:41:66 ?anon_0_
    native next
    /home/circleci/avni-client/packages/openchs-android/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:23 asyncGeneratorStep
    /home/circleci/avni-client/packages/openchs-android/node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:26 _next
    /root/react-native/packages/react-native/ReactAndroid/hermes-engine/.cxx/MinSizeRel/1h352kp3/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:53:16 tryCallOne
    /root/react-native/packages/react-native/ReactAndroid/hermes-engine/.cxx/MinSizeRel/1h352kp3/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:139:27 anonymous
    native apply
    /home/circleci/avni-client/packages/openchs-android/node_modules/react-native/Libraries/Core/Timers/JSTimers.js:247:22 anonymous
    /home/circleci/avni-client/packages/openchs-android/node_modules/react-native/Libraries/Core/Timers/JSTimers.js:111:14 _callTimer
    /home/circleci/avni-client/packages/openchs-android/node_modules/react-native/Libraries/Core/Timers/JSTimers.js:161:14 _callReactNativeMicrotasksPass
    /home/circleci/avni-client/packages/openchs-android/node_modules/react-native/Libraries/Core/Timers/JSTimers.js:415:41 callReactNativeMicrotasks
    /home/circleci/avni-client/packages/openchs-android/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:392:41 __callReactNativeMicrotasks
    /home/circleci/avni-client/packages/openchs-android/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:132:38 anonymous
    /home/circleci/avni-client/packages/openchs-android/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:368:10 __guard
    /home/circleci/avni-client/packages/openchs-android/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:131:16 flushedQueue
    /home/circleci/avni-client/packages/openchs-android/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:116:28 callFunctionReturnFlushedQueue

Testing notes
This issue does not break the UI currently as it is within a try/catch.
Needs to be tested with non dev apk (bugsnag not notified in dev apk) or if testing in dev APK following line should not be printed:
[ErrorHandler][Debug] Cannot read property 'syncEndTime' of null
Can simulate this by testing with a user with no fast sync setup, first login on a device (no previous sync telemetry records) and background sync enabled.

  • Login
  • Interrupt the sync that starts on login by killing data/wifi.
  • Wait for a minute till sync times out.
  • Background sync should trigger which should not throw the above error
@1t5j0y 1t5j0y converted this from a draft issue Nov 9, 2023
@mahalakshme mahalakshme moved this from New Issues to Ready in Avni Product Nov 9, 2023
@1t5j0y 1t5j0y moved this from Ready to In Progress in Avni Product Nov 9, 2023
@1t5j0y 1t5j0y self-assigned this Nov 9, 2023
@1t5j0y 1t5j0y moved this from In Progress to Code Review Ready in Avni Product Nov 9, 2023
@1t5j0y
Copy link
Contributor Author

1t5j0y commented Nov 9, 2023

Was unable to simulate this locally. Changed the logic to be in line with other similar existing checks to hopefully prevent this from occurring.

@himeshr himeshr moved this from Code Review Ready to In Code Review in Avni Product Nov 10, 2023
@himeshr
Copy link
Contributor

himeshr commented Nov 10, 2023

wasLastCompletedSyncDoneMoreThanHalfAnHourAgo() was supposed to return true to allow automatic sync in following scenarios:

  • After fresh login, before even the first time Manual sync is performed
  • After atleast half an hour has passed since the last sync was performed (To avoid auto-sync on every app start and Manual Sync Completion)

As per the code fix done as part of this card, we'll miss out on the first case.

@himeshr himeshr moved this from In Code Review to Code Review with Comments in Avni Product Nov 10, 2023
@1t5j0y 1t5j0y moved this from Code Review with Comments to In Progress in Avni Product Nov 10, 2023
@1t5j0y
Copy link
Contributor Author

1t5j0y commented Nov 10, 2023

Able to simulate the original error if there are no completed records in sync telemetry.
Issue was because realm still returns a non 'empty' result in this case.
Restored original check logic and changed the retrieval to fetch the latest record. Fixed the 12 hour similar check as well.

@1t5j0y 1t5j0y moved this from In Progress to Code Review Ready in Avni Product Nov 10, 2023
@himeshr himeshr moved this from Code Review Ready to In Code Review in Avni Product Nov 10, 2023
@himeshr himeshr moved this from In Code Review to QA Ready in Avni Product Nov 10, 2023
@AchalaBelokar AchalaBelokar moved this from QA Ready to In QA in Avni Product Nov 10, 2023
@AchalaBelokar AchalaBelokar moved this from In QA to Done in Avni Product Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

4 participants