Skip to content

Conversation

greghuels
Copy link
Contributor

@greghuels greghuels commented Jun 6, 2024


labels: mergeable

Fixes FF-2139

Motivation and Context

Fixes Property 'atob' doesn't exist error in React Native 0.72.x

Description

atob and btoa are not built in to React Native's JS runtime for react-native 0.72. The atob and btoa were being used by the universal-base64 package. Replacing this package with js-base64 provides a base64 implementation that doesn't rely on atob, btoa or Buffer existing.

How has this been tested?

  • I was able to reproduce the issue by creating a RN 0.72.0 app and testing with XCode / Simulator
  • I made the changes in this PR and recompiled assets to dist
  • I copied over the changed dist files, along with the newly installed js-base64 module to my node_modules/@eppo/js-client-sdk-common/dist folder and node_modules/ folders respectively
  • I rebuilt my RN app and no longer encountered the error
  • I also verified the base64 implementation by encoding 'asdf' in a browser console via btoa('asdf') then decoding the result via the library.

Before

Screenshot 2024-06-06 at 7 25 49 AM

After

Screenshot 2024-06-06 at 8 54 48 AM

@greghuels greghuels added the bug Something isn't working label Jun 6, 2024
@greghuels greghuels force-pushed the greg/FF-2139/base64-fix branch from 3db16e3 to d9ea513 Compare June 6, 2024 14:22
Copy link
Contributor

@aarsilv aarsilv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EXCELLENT job reproducing this and finding a solution that works 💪 💪 💪

"homepage": "https://github.com/Eppo-exp/js-client-sdk-common#readme",
"devDependencies": {
"@types/jest": "^29.5.11",
"@types/js-base64": "^3.3.1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📈

"md5": "^2.3.0",
"pino": "^8.19.0",
"semver": "^7.5.4",
"universal-base64": "^2.1.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🪓

@greghuels greghuels force-pushed the greg/FF-2139/base64-fix branch from d9ea513 to f330deb Compare June 6, 2024 15:42
yarn.lock Outdated
Comment on lines 788 to 792
"@types/react-native-base64@^0.2.2":
version "0.2.2"
resolved "https://registry.yarnpkg.com/@types/react-native-base64/-/react-native-base64-0.2.2.tgz#d4e1d537e6d547d23d96a1e64627acc13587ae6b"
integrity sha512-obr+/L9Jaxdr+xCVS/IQcYgreg5xtnui4Wqw/G1acBUtW2CnqVJj6lK6F/5F3+5d2oZEo5xDDLqy8GVn2HbEmw==

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops, I forgot to remove this. I was testing with this library at one point.

Copy link
Member

@leoromanovsky leoromanovsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great find! Thank you for the thorough testing, makes me feel like we will deliver a solution to the customer reliably.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants