apisauce icon indicating copy to clipboard operation
apisauce copied to clipboard

Incompatible with React Native 0.79.0 and Expo 53.0.0 - `axios` dependency

Open ChristopherGabba opened this issue 8 months ago • 20 comments

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.

ChristopherGabba avatar Apr 14 '25 01:04 ChristopherGabba

Related: https://github.com/infinitered/apisauce/issues/329

ChristopherGabba avatar Apr 14 '25 01:04 ChristopherGabba

Probably just need to upgrade axios. Will look into this shortly.

jamonholmgren avatar Apr 14 '25 14:04 jamonholmgren

Sounds good, let me know if you need anything!

ChristopherGabba avatar Apr 14 '25 15:04 ChristopherGabba

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.

lvlrSajjad avatar Apr 14 '25 20:04 lvlrSajjad

@ChristopherGabba Is the issue only when building against the NA?

robinheinze avatar Apr 15 '25 22:04 robinheinze

@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.

ChristopherGabba avatar Apr 15 '25 22:04 ChristopherGabba

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

robinheinze avatar Apr 15 '25 22:04 robinheinze

Once that PR is merged, we'll update the dependencies to the new version.

robinheinze avatar Apr 15 '25 22:04 robinheinze

Okay, yeah seems like it! I just tested it on my end with OA (lol) and I get the exact same error:

Image

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.

ChristopherGabba avatar Apr 16 '25 11:04 ChristopherGabba

From the IR community Slack:

Image

robinheinze avatar Apr 16 '25 14:04 robinheinze

So have some more info on this I think. Issue is a bit strange.

  1. If I create a new react native project and use axios itself projects builds without any polyfill needed to be added.
  2. 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.
  3. If I use apisauce installed with npm install I get issue and need to add polyfills for at least crypto, url, http, https and probably more into metro.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 avatar Apr 24 '25 07:04 andidev

@andidev That's great info. I'll dig in a bit more to see why that might be.

robinheinze avatar May 01 '25 15:05 robinheinze

There is also a new related issue filed on Axios https://github.com/axios/axios/issues/6899

robinheinze avatar May 01 '25 15:05 robinheinze

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...

ChristopherGabba avatar May 01 '25 16:05 ChristopherGabba

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.

robinheinze avatar May 02 '25 16:05 robinheinze

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"

Image

vishva-simform avatar May 05 '25 07:05 vishva-simform

@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.

Image

foresthuo avatar May 09 '25 15:05 foresthuo

@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

robinheinze avatar May 13 '25 22:05 robinheinze

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.

robinheinze avatar Jun 09 '25 17:06 robinheinze

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.

FlandiaYingman avatar Jun 14 '25 20:06 FlandiaYingman

@robinheinze Hey, the new version is released to NPM right now

saif-o99 avatar Jun 17 '25 13:06 saif-o99

@saif-o99 Thank you for the ping! I will try and get a new version up today

robinheinze avatar Jun 19 '25 16:06 robinheinze

https://github.com/infinitered/apisauce/releases/tag/v3.2.0 is out!

robinheinze avatar Jun 19 '25 17:06 robinheinze