8000 Attempt to address reported NPE on startup by jhaven-stytch · Pull Request #236 · stytchauth/stytch-android · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Attempt to address reported NPE on startup #236

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

Merged
merged 3 commits into from
Dec 11, 2024
Merged

Conversation

jhaven-stytch
Copy link
Contributor
@jhaven-stytch jhaven-stytch commented Dec 11, 2024

Linear Ticket: SDK-2311

Changes:

  1. Moves the declaration of the flows to the top of the file, on the off-chance that somehow a value is being set (and trying to emit) before the flow has been created? Since Kotlin classes are created top-to-bottom, the "source" properties were being created before the flows. I'm unsure how the source property setters would be called before the flows were created, though.
  2. Initializes the flows with a null value and then emits the desired value in the new-at-the-bottom init method? This goes along with the above. If I move the property initializers above the "source" properties, I don't want the source property initialization to happen before the flows are created.
  3. Replace the emit calls with tryEmit, which removes the need for launching in a coroutine. Both methods are thread-safe, but maybe that gets out-of-whack when the emissions were launched in the application-level scope (ie: trying to call a method from Thread 2 on a property created on Thread 1)? We don't need the suspending fallback of emit because we're the only ones observing these flows AND we're guaranteed to not be listening to them until AFTER the session storages have been initialized due to the lazy delegation in the clients.

Notes:

  • I have been unable to reproduce the reported crash, so this is kind of a blind guess as to what could be going on
  • Consider this a WIP for now. I'm waiting to hear back from the customer on if there are reliable repro steps, and will do some more thinking on these changes, but wanted to get something up in the interim.

Checklist:

  • I have verified that this change works in the relevant demo app, or N/A
  • I have added or updated any tests relevant to this change, or N/A
  • I have updated any relevant README files for this change, or N/A

@jhaven-stytch jhaven-stytch requested a review from a team as a code owner December 11, 2024 16:50
@jhaven-stytch
Copy link
Contributor Author

cc: @mruhlin-stytch

@jhaven-stytch jhaven-stytch merged commit 5e5b93e into main Dec 11, 2024
4 checks passed
@jhaven-stytch jhaven-stytch deleted the jordan/npe-on-startup branch December 11, 2024 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0