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

Undici doesn't work with npm specifiers #16710

Closed
khrj opened this issue Nov 19, 2022 · 14 comments · Fixed by denoland/std#3102
Closed

Undici doesn't work with npm specifiers #16710

khrj opened this issue Nov 19, 2022 · 14 comments · Fixed by denoland/std#3102
Assignees
Labels
bug Something isn't working correctly node compat

Comments

@khrj
Copy link
Contributor

khrj commented Nov 19, 2022

Undici returns a ConnectTimeoutError when attempting any request.

Many npm modules depend on undici, node's fetch api implementation used as a module.

Reproducible example:

import { request } from "npm:undici"
await request("https://www.example.com")

fails with

error: Uncaught (in promise) ConnectTimeoutError: Connect Timeout Error
    at onConnectTimeout (file:///home/khushraj/.cache/deno/npm/registry.npmjs.org/undici/5.12.0/lib/core/connect.js:133:24)
    at file:///home/khushraj/.cache/deno/npm/registry.npmjs.org/undici/5.12.0/lib/core/connect.js:80:46
    at Timeout.<anonymous> (file:///home/khushraj/.cache/deno/npm/registry.npmjs.org/undici/5.12.0/lib/core/connect.js:121:9)
    at https://deno.land/std@0.164.0/node/timers.ts:21:15
    at Object.action (deno:ext/web/02_timers.js:147:13)
    at handleTimerMacrotask (deno:ext/web/02_timers.js:64:12)

Example of module broken: #16684

@kt3k
Copy link
Member

kt3k commented Nov 21, 2022

I found 3 issues for this:

@bartlomieju
Copy link
Member

Seems like there's another problem: #15427 (comment)

@khrj
Copy link
Contributor Author

khrj commented Dec 7, 2022

Any progress on Deno.TcpConn.unref / is there something blocking it?

@bartlomieju
Copy link
Member

Any progress on Deno.TcpConn.unref / is there something blocking it?

No progress, no one has picked it up yet. PRs are most welcome!

@bartlomieju
Copy link
Member

FYI I'm working on the ref/unref functionality in #17170

bartlomieju added a commit that referenced this issue Dec 28, 2022
This commit adds "Deno.Conn.ref()" and "Deno.Conn.unref()" methods.

These methods can be used to make connection block or not block the
event loop from finishing. Refing/unrefing only influences "read" 
operations - ie. scheduling writes to a connection _do_ keep event 
loop alive.

Required for #16710
@bartlomieju bartlomieju removed their assignment Dec 29, 2022
@bartlomieju
Copy link
Member

@kt3k could you take over this issue now that unref API for connection is implemented?

@kt3k
Copy link
Member

kt3k commented Dec 30, 2022

Sure!

@kt3k kt3k self-assigned this Dec 30, 2022
bartlomieju added a commit that referenced this issue Jan 5, 2023
This commit adds "Deno.Conn.ref()" and "Deno.Conn.unref()" methods.

These methods can be used to make connection block or not block the
event loop from finishing. Refing/unrefing only influences "read" 
operations - ie. scheduling writes to a connection _do_ keep event 
loop alive.

Required for #16710
@khrj
Copy link
Contributor Author

khrj commented Jan 8, 2023

@kt3k as of 1.29.2, this seems to be completely functional now? Is there something that is still pending, or should I close this issue? The example in the original post works now. Thanks!

@Jakob5358
Copy link

@khrj It still seems to time out for me, both on 1.29.2 and on latest canary.

import { request } from 'npm:undici';

const res = await request('https://jsonplaceholder.typicode.com/todos/1');
console.log(res.statusCode);

@khrj
Copy link
Contributor Author

khrj commented Jan 9, 2023

Apart from being rather slow, it works for me:

image

Running deno from master

@khrj
Copy link
Contributor Author

khrj commented Jan 9, 2023

In comparison:

image

@Jakob5358
Copy link

Apart from being rather slow, it works for me:

image

Running deno from master

Weird, this is what happens for me running deno... not from master but from latest canary.
image
Maybe I'm not using the latest deno_std version for node compat and you need to set that manually idk-

@kt3k
Copy link
Member

kt3k commented Jan 13, 2023

@Jakob5358 Is https://jsonplaceholder.typicode.com/todos/1 accessible from your environment?

@Jakob5358
Copy link

@Jakob5358 Is https://jsonplaceholder.typicode.com/todos/1 accessible from your environment?

Yes but it now works in the latest version thanks y'all

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 compat
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants