question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Undici throws a ConnectTimeoutError when there is no connection

See original GitHub issue

Bug Description

If you try to send an HTTP request, but the DNS lookup for the requested domain name fails, Undici may throw a ConnectTimeoutError.

Reproducible By

I wrote a simple script which reproduces the issue

const { Pool } = require('undici')

const agent = new Pool('http://foobar.bar')

for (let i = 0; i < 500; i++) {
  agent.request({ method: 'GET', path: '/foobar' })
    .then(async ({ body }) => {
      for await (const data of body) {
        console.log('data', data.toString('utf8'))
      }
    })
    .catch(console.error)
}

I used undici@5.4.0

Expected Behavior

I’d expect to get only errors which indicate that the DNS lookup has failed.

Logs & Screenshots

Video

Environment

Ubuntu 20.04.4 LTS, Node v16.13.0

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
jodevsacommented, Jul 15, 2022
0reactions
jodevsacommented, Jul 16, 2022

reproduce script:

const { Pool } = require('undici')
const assert = require('assert')
const agent = new Pool('http://foobar.bar')

for (let i = 0; i < 50000; i++) {
  agent.request({ method: 'GET', path: '/foobar' })
    .then(async ({ body }) => {
      for await (const data of body) {
        console.log('data', data.toString('utf8'))
      }
    })
    .catch((e)=>assert.equal(e.code,'ENOTFOUND'))
}

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pip Install Timeout Issue - python - Stack Overflow
when I tried to access the site : https://pypi.org/project/pandas/#files I can access it without any problem on explorer.
Read more >
Intermittent ConnectTimeoutError accessing SSM - AWS re:Post
My app uses SSM Parameter Store on Fargate instances and locally in a Docker container. We're accessing it with Boto3 from Python. Multiple...
Read more >
Hardhat mumbai forking is throwing ConnectTimeoutError
Apparently, it is thrown at getContractFactory call. ConnectTimeoutError: Connect Timeout Error at Timeout.onConnectTimeout [as _onTimeout] ...
Read more >
A Complete Guide to Timeouts in Node.js - Better Stack
It is set to 0 by default which means no timeout, giving the possibility of a connection that hangs forever. To fix this,...
Read more >
Connect timeout and execution timeout in nodejs driver
Vlad_Kote (Vlad Kote) March 29, 2020, 11:01pm #1. Hi Guys! I hope I'm posting this in ... It does not have a direct...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found