Repository: denoland/deno (language: rust)

Issue:
[Bug] "Request failed." error since deno 2.1.5 (`npm:twitter-api-v2`)
Version: Any above 2.1.5, tested on 2.1.6 and 2.1.7 as well

I utilize the `twitter-api-v2` package and noticed that starting on the 23rd I started getting this `request failed.` error on Deno Deploy. Upon investigating locally whenever I try to do any api request via the package using deno 2.1.5 or newer it gives an error but version 2.1.4 works fine. I've also tested my code on both node and bun and it works fine there.

![Image](https://github.com/user-attachments/assets/50fcc548-aa35-4714-8d8f-6c3194ca3e62)

Code: https://gist.github.com/Blocksnmore/78e3d5280f4e7e941191eb62bde47773


Discussion / hints:
This might be related to dns resolution timeout issue.

What happens if you add the below script at the top of your script?:

```js
import net from "node:net";
net.setDefaultAutoSelectFamilyAttemptTimeout(5000);
```
> This might be related to dns resolution timeout issue.
> 
> What happens if you add the below script at the top of your script?:
> 
> import net from "node:net";
> net.setDefaultAutoSelectFamilyAttemptTimeout(5000);

Unfortunately this does not resolve the issue (tested on 2.1.7), I'm given the following stack trace using the same code as before alongside your addition at the top
```ts
error: Uncaught (in promise) Error: Request failed.
    at RequestHandlerHelper.createRequestError (file:///home/blocks/.cache/deno/npm/registry.npmjs.org/twitter-api-v2/1.19.0/dist/cjs/client-mixins/request-handler.helper.js:58:16)
    at RequestHandlerHelper.onSocketCloseHandler (file:///home/blocks/.cache/deno/npm/registry.npmjs.org/twitter-api-v2/1.19.0/dist/cjs/client-mixins/request-handler.helper.js:218:32)
    at Socket.emit (ext:deno_node/_events.mjs:405:35)
    at node:net:1157:14
    at processTicksAndRejections (ext:deno_node/_next_tick.ts:28:11)
    at runNextTicks (ext:deno_node/_next_tick.ts:76:3)
    at eventLoopTick (ext:core/01_core.js:184:21)
```
I can confirm that this issue still occurs on the latest version of deno (2.1.9) 

Fix patch:
diff --git a/ext/node/polyfills/net.ts b/ext/node/polyfills/net.ts
index d7a3183e41c673..a9a3da12efe271 100644
--- a/ext/node/polyfills/net.ts
+++ b/ext/node/polyfills/net.ts
@@ -1168,6 +1168,7 @@ const pkgsNeedsSockInitWorkaround = [
   "@npmcli/agent",
   "npm-check-updates",
   "playwright-core",
+  "twitter-api-v2",
 ];
 
 /**


Test patch: