sindresorhus / is-network-error

Check if a value is a Fetch network error
MIT License
122 stars 6 forks source link

Consider supporting Bun and Deno #6

Open brettwillis opened 1 month ago

brettwillis commented 1 month ago

Taking a glance over your implementation, it doesn't specifically call out Bun or Deno. Would you consider it?

It looks like Deno might be the same as Firefox, but not sure how to confidently validate that: https://github.com/denoland/deno/blob/9a83efa04b6e733ca0fdbf9e780c4b77f0d9f4be/ext/fetch/lib.rs#L177.

And Bun might be different again, A network error occurred. with a space on the front no less: https://github.com/oven-sh/bun/blob/3876ecfde8acabc69a6fa83520166ed8fe9cb05f/src/bun.js/bindings/DOMException.cpp#L54.

sindresorhus commented 1 month ago

Happy to support them.

brettwillis commented 1 month ago

Bun's situation is inherited from WebKit: https://github.com/WebKit/WebKit/blob/43d96aea3b91c8448de449b4d36252eda0c6eb3f/Source/WebCore/dom/DOMException.cpp#L54

NetworkError: A network error occurred.

Haven't actually tested just noodling around in source code.

sindresorhus commented 1 month ago

And Bun might be different again, A network error occurred. with a space on the front no less: oven-sh/bun@3876ecf/src/bun.js/bindings/DOMException.cpp#L54.

That's likely a typo. The spec doesn't have any space prefix. You should report it on WebKit.

brettwillis commented 1 month ago

There's another one I see in Cloudflare workerd runtime (V8-based). I definitely see it in the local dev server but unsure how well it's related to their production runtime: Network connection lost. instance of plain Error.

https://github.com/cloudflare/workerd/blob/dd7e46377237d557375dab5c014310693719b48c/src/workerd/jsg/util.c%2B%2B#L282

brettwillis commented 1 month ago

From searching around the community it looks like Network connection lost. is definitely also the error message in the Cloudflare Workers production runtime, too.