News for hackers. Stuff that matters.
Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by afavour on Tuesday March 31, 2026 @07:58AM (#47586074)
Irony is that Node has no need for Axios, native fetch support has been there for years, so in terms of network requests it is batteries included.
Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by pier25 on Tuesday March 31, 2026 @09:12AM (#47586877)
People use axios or ky because with fetch you inevitably end up writing a small wrapper on top of it anyway.
Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by zachrip on Tuesday March 31, 2026 @10:57AM (#47588281)
Fetch has also lacked support for features that xhr has had for over a decade now. For example upload progress. It's slowly catching up though, upload progress is the only thing I'd choose xhr for.
Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by apitman on Tuesday March 31, 2026 @04:26PM (#47593003)
You can pipe through a TransformStream that counts how many bytes you've uploaded, right?
Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by zachrip on Tuesday March 31, 2026 @05:39PM (#47593823)
That is a way to approximate it, though I'd be curious to know the semantics compared to xhr - would they both show the same value at the same network lifecycle of a given byte?
Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by afavour on Wednesday April 01, 2026 @07:09AM (#47599311)
That would show how quickly the data is passing into the native fetch call but doesn’t account for kind of internal buffer it might have, network latency etc
Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by jmull on Tuesday March 31, 2026 @10:20AM (#47587793)
In my experience people feel the need to wrap axios too.
Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by kube-system on Tuesday March 31, 2026 @02:43PM (#47591691)
These are the kind of people I hope AI replaces
Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by nathancahill on Tuesday March 31, 2026 @03:53PM (#47592572)
AI was trained on Axios wrappers, so it's just going to be wrappers all the way down. Look inside any company "API Client" and it's just a branded wrapper around Axios.
Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by kube-system on Tuesday March 31, 2026 @04:29PM (#47593042)
Speak for yourself, Claude works fine with fetch on my system.
Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by lukeschlather on Wednesday April 01, 2026 @11:08AM (#47601944)
I have never consciously wrapped Axios or fetch, but a cursory search suggests that there was a time when it was impossible for either to force TLS1.3. It's easy to imagine alternate implementations exist for frivolous reasons, but sometimes there are hard security or performance requirements that force you into them.
Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by afavour on Tuesday March 31, 2026 @09:14AM (#47586894)
Some might say the tradeoff of writing a small wrapper is worth it given what’s been demonstrated here.
Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by pier25 on Tuesday March 31, 2026 @09:41AM (#47587261)
Yeah but what about other deps like db drivers?
Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by cyco130 on Tuesday March 31, 2026 @09:32AM (#47587131)
I'm not sure fetch is a good server-side API. The typical fetch-based code snippet `fetch(API_URL).then(r => r.json())` has no response body size limit and can potentially bring down a server due to memory exhaustion if the endpoint at API_URL malfunctions for some reason. Fine in the browser but to me it should be a no-no on the server.
Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by augusto-moura on Tuesday March 31, 2026 @09:43AM (#47587299)
Hm, I don't think axios would do much better here. `fetch` is the official replacement for axios. If both are flawed that's another topic
Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by cyco130 on Tuesday March 31, 2026 @11:24AM (#47588736)
Axios has maxContentLength and maxBodyLength options. I would probably go with undici nowadays though (it also has maxResponseSize).
Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by nailer on Tuesday March 31, 2026 @11:14AM (#47588559)
> `fetch` is the official replacement for axios.

No. Axios is still maintained. They have not deprecated the project in favor of fetch.

Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by augusto-moura on Tuesday March 31, 2026 @12:21PM (#47589726)
I'm not saying that axios is unmaintained, I'm saying that if you want something like axios from the standard lib, fetch is the closest thing you get to official
Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by nailer on Tuesday March 31, 2026 @04:59PM (#47593398)
Sure but Axios determine what the official replacement for Axios is.
Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by kube-system on Tuesday March 31, 2026 @02:45PM (#47591719)
It's not deprecated, it's obsoleted.
Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by lelanthran on Tuesday March 31, 2026 @04:14PM (#47592832)
> I'm not sure fetch is a good server-side API. The typical fetch-based code snippet `fetch(API_URL).then(r => r.json())` has no response body size limit and can potentially bring down a server due to memory exhaustion if the endpoint at API_URL malfunctions for some reason. Fine in the browser but to me it should be a no-no on the server.

Nor is fetch a good client-side API either; you want progress indicators, on both upload and download. Fetch is a poor API all-round.

Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by WorldMaker on Wednesday April 01, 2026 @11:57AM (#47602602)
You can pass to `fetch` an `AbortSignal` like `AbortSignal.timeout(5000)` as a simple and easy guard.

If you also want to guard on size, iterating the `response.body` stream with for/await/of and adding a counter that can `abort()` a manual `AbortSignal` is relatively straightforward, though sounds complicated. You can even do that as a custom `ReadableStream` implementation so that you can wrap it back into `Response` and still use the `response.json()` shortcut. I'm surprised I'm not seeing a standard implementation of that, but it also looks straightforward from MDN documentation [1].

[1] https://developer.mozilla.org/en-US/docs/Web/API/Streams_API...

Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by vakrdotme on Wednesday April 01, 2026 @02:28PM (#47604656)
Browser fetch can lean on the fact that the runtime environment has hard limits per tab and the user will just close the tab if things get weird. on the server you're right
Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by augusto-moura on Tuesday March 31, 2026 @09:42AM (#47587269)
It doesn't have a need _now_. Axios is more than 10 years old now, and even before axios other libraries did the same utility of making requests easier
Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by MBCook on Tuesday March 31, 2026 @11:28AM (#47588813)
Browsers too.

It’s not needed anymore.

Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by zadikian on Tuesday March 31, 2026 @12:27PM (#47589832)
Node fetch is relatively new. Wasn't marked stable until 2023, though I've used it since like 2018.
Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by fishpen0 on Tuesday March 31, 2026 @01:35PM (#47590838)
It doesn't matter. We pulled axios out of our codebase, but it still ends up in there as a child or peer from 40 other dependencies. Many from major vendors like datadog, slack, twilio, nx (in the gcs-cache extension), etc...
Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by jamesfinlayson on Tuesday March 31, 2026 @10:43PM (#47596153)
Yep, got stung because a bunch of things still pull in axios even though we don't use it.
Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by CountHackulus on Wednesday April 01, 2026 @10:56AM (#47601794)
Every time I'm reminded of this article about package managers. https://www.gingerbill.org/article/2025/09/08/package-manage...
Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by tyingq on Wednesday April 01, 2026 @01:31PM (#47603924)
Serverless framework up until late yesterday also.
Re:Axios Compromised on NPM – Malicious Versions Drop Remote... by Chyzwar on Wednesday April 01, 2026 @05:41PM (#47606894)
Because native fetch lack retries, error handling is verbose, search and body serialization create ton of boilerplate. I use KY http client, small lib on top of fetch with great UX and trusted maintainer.