Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm:undici not working (Connect Timeout Error) #19532

Open
KohnoseLami opened this issue Jun 16, 2023 · 4 comments
Open

npm:undici not working (Connect Timeout Error) #19532

KohnoseLami opened this issue Jun 16, 2023 · 4 comments
Labels
bug Something isn't working correctly node API polyfill Related to various "node:*" modules APIs node compat node:http Issues with `node:http` module - to be fixed with a rewrite windows Related to Windows platform

Comments

@KohnoseLami
Copy link

KohnoseLami commented Jun 16, 2023

It appears to have been resolved as a result of the following issue, but it still does not work in my environment.
#16710

PS D:\Desktop\Projects\Discord\Deno> node index.mjs
{
  data: {
    t: 'READY',
    s: 1,
    op: 0,
    d: {
      v: 10,
      user_settings: {},
      user: [Object],
      shard: [Array],
      session_type: 'normal',
      session_id: '329437320dbddd3c074ac6ca6815161e',
      resume_gateway_url: 'wss://gateway-us-east1-b.discord.gg',
      relationships: [],
      private_channels: [],
      presences: [],
      guilds: [Array],
      guild_join_requests: [],
      geo_ordered_rtc_regions: [Array],
      application: [Object],
      _trace: [Array]
    }
  },
  shardId: 0
}
PS D:\Desktop\Projects\Discord\Deno> deno run --allow-all index.ts
error: Uncaught (in promise) ConnectTimeoutError: Connect Timeout Error
    at onConnectTimeout (file:///D:/Desktop/Projects/Discord/Deno/node_modules/.deno/undici@5.22.1/node_modules/undici/lib/core/connect.js:182:24)
    at file:///D:/Desktop/Projects/Discord/Deno/node_modules/.deno/undici@5.22.1/node_modules/undici/lib/core/connect.js:129:46
    at file:///D:/Desktop/Projects/Discord/Deno/node_modules/.deno/undici@5.22.1/node_modules/undici/lib/core/connect.js:168:33
    at Object.action (ext:deno_web/02_timers.js:153:11)
    at handleTimerMacrotask (ext:deno_web/02_timers.js:67:10)
    at eventLoopTick (ext:core/01_core.js:189:21)

I used @discordjs/rest to test the behavior, but only undici actually causes errors.

import { request } from "npm:undici"
await request("https://jsonplaceholder.typicode.com/todos/1")

My enviroments:
deno 1.34.3 (release, x86_64-pc-windows-msvc)
v8 11.5.150.2
typescript 5.0.4

@crowlKats
Copy link
Member

I am not able to reproduce this; possibly a windows specific error?

@KohnoseLami
Copy link
Author

KohnoseLami commented Jul 11, 2023

Maybe yes
I prepared another Windows machine for the experiment and did it from installation, but I get a similar error.
I ran it on Windows 11 and Windows 10 and it was similar.

PS C:\Users\Lami> irm https://deno.land/install.ps1 | iex
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 30.3M  100 30.3M    0     0  30.3M      0  0:00:01 --:--:--  0:00:01 30.3M
Deno was installed successfully to C:\Users\Lami\.deno\bin\deno.exe
Run 'deno --help' to get started
Stuck? Join our Discord https://discord.gg/deno
PS C:\Users\Lami> deno
Deno 1.35.0
exit using ctrl+d, ctrl+c, or close()
REPL is running with all permissions allowed.
To specify permissions, run `deno repl` with allow flags.
> import { request } from "npm:undici"
await request("https://jsonplaceholder.typicode.com/todos/1")
Uncaught ConnectTimeoutError: Connect Timeout Error
    at onConnectTimeout (file:///C:/Users/Lami/AppData/Local/deno/npm/registry.npmjs.org/undici/5.22.1/lib/core/connect.js:182:24)
    at file:///C:/Users/Lami/AppData/Local/deno/npm/registry.npmjs.org/undici/5.22.1/lib/core/connect.js:129:46
    at file:///C:/Users/Lami/AppData/Local/deno/npm/registry.npmjs.org/undici/5.22.1/lib/core/connect.js:168:33
    at Object.action (ext:deno_web/02_timers.js:153:11)
    at handleTimerMacrotask (ext:deno_web/02_timers.js:67:10)
    at eventLoopTick (ext:core/01_core.js:189:21)
>

Of course fetch works in environments where undici doesn't work. So it's not about the network or anything.

> await fetch('https://jsonplaceholder.typicode.com/todos/1')
Response {
  body: ReadableStream { locked: false },
  bodyUsed: false,
  headers: Headers {
  "access-control-allow-credentials": "true",
  age: "630",
  "alt-svc": 'h3=":443"; ma=86400',
  "cache-control": "max-age=43200",
  "cf-cache-status": "HIT",
  "cf-ray": "7e4d1b900aca2635-NRT",
  "content-type": "application/json; charset=utf-8",
  date: "Tue, 11 Jul 2023 01:00:07 GMT",
  etag: 'W/"53-hfEnumeNh6YirfjyjaujcOPPT+s"',
  expires: "-1",
  nel: '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}',
  pragma: "no-cache",
  "report-to": '{"endpoints":[{"url":"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=8JU1QfR3ezrPM5UYvJGo2DY43mIdswRNi'... 179 more characters,
  server: "cloudflare",
  vary: "Origin, Accept-Encoding",
  via: "1.1 vegur",
  "x-content-type-options": "nosniff",
  "x-powered-by": "Express",
  "x-ratelimit-limit": "1000",
  "x-ratelimit-remaining": "999",
  "x-ratelimit-reset": "1683994374"
},
  ok: true,
  redirected: false,
  status: 200,
  statusText: "OK",
  url: "https://jsonplaceholder.typicode.com/todos/1"
}

@bartlomieju bartlomieju added the windows Related to Windows platform label Jul 20, 2023
@bartlomieju bartlomieju assigned bartlomieju and unassigned crowlKats Jul 20, 2023
@bartlomieju bartlomieju removed their assignment Mar 4, 2024
@bartlomieju bartlomieju added the node API polyfill Related to various "node:*" modules APIs label Mar 4, 2024
@kravetsone
Copy link

+1.

I try to use it in WSL and all works fine.
But if I switch to Windows I get the same error...

It is lock to use my framework on Windows in Deno runtime...

https://gramio.netlify.app/
https://jsr.io/@gramio/core

@bartlomieju bartlomieju added the node:http Issues with `node:http` module - to be fixed with a rewrite label Jul 1, 2024
@kravetsone
Copy link

import { request } from "npm:undici";

console.log(await request("https://jsonplaceholder.typicode.com/todos/1"));

Seems like it works now on Deno 2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly node API polyfill Related to various "node:*" modules APIs node compat node:http Issues with `node:http` module - to be fixed with a rewrite windows Related to Windows platform
Projects
None yet
Development

No branches or pull requests

4 participants