Incompatible with React Native 0.79.0 and Expo 53.0.0 - `axios` dependency
I tried upgrading my app to the latest and greatest just to do a dependency test on the new architecture and apisauce blocked the build, no matter what I messed with. I tried yarns resolutions, etc and it never would compile.
It seems to be related to dependencies of axios - crypto, url, etc. and not being compatible with node.
Related: https://github.com/infinitered/apisauce/issues/329
Probably just need to upgrade axios. Will look into this shortly.
Sounds good, let me know if you need anything!
I tried upgrading axios manually but I am still getting this error. The interesting point is my IDE finds the crypto when I command click but when getting compiled it doesn't include crypto properly.
@ChristopherGabba Is the issue only when building against the NA?
@robinheinze if by NA you mean New Architecture (I had to ask gpt lol), I have not tried bumping to 0.79.0 and Expo 53 on old architecture yet. It is for sure present on the new architecture, but I can test on old tomorrow and get back to you.
Haha, sorry 😅 Based on some digging I think it's affecting both.. It's an axios breaking change introduced in 1.8.0. There's currently a PR that is open but not merged. https://github.com/axios/axios/pull/6802.
Seems like for now the best solution is to pin the Axios version to 1.7.9 https://github.com/infinitered/apisauce/issues/329#issue-2880448006
Once that PR is merged, we'll update the dependencies to the new version.
Okay, yeah seems like it! I just tested it on my end with OA (lol) and I get the exact same error:
When I put a resolution and pin it to 1.7.9, I think I get the same error, except the "crypto" library is replaced with a library called "url". I may be wrong, but that's what I remember too.
From the IR community Slack:
So have some more info on this I think. Issue is a bit strange.
- If I create a new react native project and use axios itself projects builds without any polyfill needed to be added.
- If I copy paste the source code from lib/apisauce.ts into my project and use it directly instead of installing apisauce with npm projects builds without any polyfill needed to be added.
- If I use apisauce installed with npm install I get issue and need to add polyfills for at least
crypto,url,http,httpsand probably more intometro.config.js. I used
resolver: {
extraNodeModules: require('@pagopa/react-native-nodelibs'),
},
which adds a lot of polyfills but I still cannot get it to work since its impossible to polyfill all without an error in the polyfill itself.
So why does 1. and 2. work and why does 3. require lots of polyfills?
@andidev That's great info. I'll dig in a bit more to see why that might be.
There is also a new related issue filed on Axios https://github.com/axios/axios/issues/6899
Thanks guys for looking into this. This is the last hurdle for me to get to expo 53, so hopefully someone with axios gets a handle on it...
Here's another workaround from a metro issue https://github.com/facebook/metro/issues/1272#issuecomment-2182873613. As soon as there's a stable fix in Axios we'll release a new version.
Is there any update on this issue? I'm experiencing the same problem after upgrading my SDK to 53 and React Native to 0.79. For reference, here are the relevant dependencies from my package.json: "apisauce": "^3.1.1", "axios": "^1.9.0"
@robinheinze Hi, axios has fixed the problem in 1.8.1, could you please to release a new version? Our project is blocked by this problem. Thanks.
@foresthuo 1.8.1 has been out for a while and other folks in this thread have said in this thread it doesn't solve the issue. @vishva-simform is on 1.9.0 for example and is still facing it.
There are workarounds that others have said successfully unblocked them if you read through the comments here https://github.com/axios/axios/issues/6899#issuecomment-2864940687
Another update: https://github.com/axios/axios/pull/6933 was merged yesterday 🎉 As soon as it is released to NPM as a new version I will update this package.
A new axios version is released fixing the problem. For those who want to use it without waiting, add
"resolutions": {
"axios": "^1.10.0"
},
to package.json to override the axios verion.
@robinheinze Hey, the new version is released to NPM right now
@saif-o99 Thank you for the ping! I will try and get a new version up today
https://github.com/infinitered/apisauce/releases/tag/v3.2.0 is out!