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

fix: onTokenChange method causing app to crash #3552

Merged
merged 7 commits into from
May 5, 2020

Conversation

focux
Copy link
Contributor

@focux focux commented Apr 27, 2020

Description

After being several days trying to find what was causing my app to crash with a very undetailed message:

TypeError: Properties can only be defined on Objects

I found that the error is due to calling onTokenChange method from the messaging package. It was trying to define a new property in a string instead of doing it in his proto. Also, it seems that bug what's introduced by this commit 1940d6c.

Related issues

Release Summary

Fix onTokenChange bug that was crashing app.

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
    • Yes
  • My change supports the following platforms;
    • Android
    • iOS
  • I have updated TypeScript types that are affected by my change.
  • This is a breaking change;
    • Yes
    • No

Think react-native-firebase is great? Please consider supporting the project with any of the below:

@CLAassistant
Copy link

CLAassistant commented Apr 27, 2020

CLA assistant check
All committers have signed the CLA.

@Ehesp Ehesp requested a review from Salakar April 27, 2020 07:36
@Salakar
Copy link
Member

Salakar commented Apr 27, 2020

Is this Hermes by any chance? Guessing it is

Also we're planning on removing this now, was just a hacky backwards compatibility fix - though I'm fine to merge this fix until we remove it

@Salakar Salakar linked an issue Apr 27, 2020 that may be closed by this pull request
10 tasks
@focux
Copy link
Contributor Author

focux commented Apr 27, 2020 via email

@Salakar
Copy link
Member

Salakar commented Apr 27, 2020

Thanks for replying - I'd be inclined then to just remove the work around entirely then I think, let's remove the Object.defineProperty and change listener(tokenStringWithTokenAccessor); to listener(token);.

Each RNFirebase package is independently versioned so I don't see any harm in going ahead with the breaking change now - if you don't mind making the change?

Once merged a new semver major of messaging will get automatically published to NPM, so can get this out pretty quickly

@focux
Copy link
Contributor Author

focux commented Apr 28, 2020

Great! I just pushed the requested changes. Let me know if it's okay or if you want to change anything.

@Salakar
Copy link
Member

Salakar commented Apr 28, 2020

Awesome, thanks! I'll get this reviewed and released tomorrow (late here) 🎉

@Salakar Salakar self-assigned this Apr 28, 2020
@Salakar Salakar added plugin: messaging FCM only - ( messaging() ) - do not use for Notifications impact: breaking-change A PR that introduces a breaking change. platform: javascript labels Apr 28, 2020
@alexfoxy
Copy link

alexfoxy commented May 5, 2020

@Salakar getting this issue, when will this fix be merged into a release?

@mikehardy
Copy link
Collaborator

@focux check out the patch-package package - if you try it yourself and it works, you have a nice persistent (across CI other devs etc) fix locally plus you can report success here - win/win

@focux
Copy link
Contributor Author

focux commented May 5, 2020

@focux check out the patch-package package - if you try it yourself and it works, you have a nice persistent (across CI other devs etc) fix locally plus you can report success here - win/win

Actually, I already use patch-package and I applied the fix since day one, it's working well. We just need to get this PR merged and publish a new major. I think that @Salakar was going to do that.

@Salakar Salakar merged commit 1d7cd28 into invertase:master May 5, 2020
@Salakar
Copy link
Member

Salakar commented May 5, 2020

Batching a few commits into the next release (nothing extreme) so will manually trigger a release tomorrow, sorry for the delay 🙈

@Salakar Salakar mentioned this pull request May 5, 2020
1 task
@focux
Copy link
Contributor Author

focux commented May 6, 2020

Love it. Thank you.

@smxdevst
Copy link

Any updates when this one will be publishing? @Salakar

stefkampen pushed a commit to stefkampen/react-native-firebase that referenced this pull request Jun 6, 2020
Removed deprecation.

* fix: onTokenChange method causing app to crash

* fix: use token instead of token with string ancestor

Co-authored-by: Mike Diarmid <mike.diarmid@gmail.com>
hmhm2292 pushed a commit to hmhm2292/react-native-firebase that referenced this pull request Jul 13, 2021
Removed deprecation.

* fix: onTokenChange method causing app to crash

* fix: use token instead of token with string ancestor

Co-authored-by: Mike Diarmid <mike.diarmid@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impact: breaking-change A PR that introduces a breaking change. platform: javascript plugin: messaging FCM only - ( messaging() ) - do not use for Notifications
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🔥 App Crashes on first launch if using messaging().onTokenRefresh(...)
6 participants