GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — dns and retry with pre-built interceptors error · Issue #3901 · nodejs/undici

dns and retry with pre-built interceptors error #3901

New issue
Copy link
New issue
Copy link
Closed
#3903
Closed
dns and retry with pre-built interceptors error#3901
#3903
Copy link
Labels
bugSomething isn't working

Description

@haydnhkim
haydnhkim
opened on Nov 29, 2024
Issue body actions

Bug Description

When I use dns and retry with pre-built interceptors, I get no response.
If I keep the process alive as I did when using express, I get the error below.

Reproducible By

import { Agent, setGlobalDispatcher, interceptors } from 'undici';

const { dns, retry } = interceptors;
const agent = new Agent({
  connect: {
    rejectUnauthorized: false,
  },
}).compose([
  dns({
    maxTTL: 60 * 60 * 1000,
    maxItems: 10000,
  }),
  retry({
    maxRetries: 2,
    maxTimeout: 5 * 1000,
  }),
]);

setGlobalDispatcher(agent);

(async () => {
  const todo = await fetch('https://jsonplaceholder.typicode.com/todos/1')
    .then((res) => res.json())
    .catch(console.error);

  console.log(JSON.stringify(todo, null, 2));
})();

Expected Behavior

A response to the request should occur and console.log should be printed.

{
  "userId": 1,
  "id": 1,
  "title": "delectus aut autem",
  "completed": false
}

Logs & Screenshots

The error below does not always occur immediately.
They occur after a period of time after multiple requests without receiving a response.

uncaughtException: TypeError: this[#handler].onError is not a function
    at DNSDispatchHandler.onError (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]/node_modules/undici/lib/interceptor/dns.js:267:23)
    at Request.onError (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]/node_modules/undici/lib/core/request.js:301:27)
    at Object.errorRequest (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]/node_modules/undici/lib/core/util.js:828:13)
    at Socket.onHttpSocketClose (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]/node_modules/undici/lib/dispatcher/client-h1.js:939:10)
    at Socket.emit (node:events:530:35)
    at TCP.<anonymous> (node:net:337:12)
    at TCP.callbackTrampoline (node:internal/async_hooks:130:17)

  Exception origin: uncaughtException
  ⨯ ../../node_modules/.pnpm/[email protected]/node_modules/undici/lib/interceptor/dns.js (267:1) @ DNSDispatchHandler.onError
  ⨯ uncaughtException: [TypeError: this[#handler].onError is not a function]
   265 |       // eslint-disable-next-line no-fallthrough
   266 |       default:
 > 267 |         this.#handler.onError(err)
       | ^
   268 |         break
   269 |     }
   270 |   }

Environment

MacOS Sequoia 15.0
Node.js v 20.17.0
Node.js v 22.11.0

7.0.0-alpha.6 ~ 7.0.0-alpha.8 → Works fine
7.0.0-alpha.9 and later (include stable v7) → Doesn't work. No output to console.log

Activity

  1. haydnhkim
    added
    bugSomething isn't working
    on Nov 29, 2024
  2. haydnhkim
    changed the title [-]dns with pre-built interceptors error[/-] [+]dns and retry with pre-built interceptors error[/+] on Nov 29, 2024
  3. metcoder95
    added a commit that references this issue on Nov 29, 2024

    fix(#3901): migrate dns interceptor to new hooks

    b38f288
  4. metcoder95
    closed this as completedin #3903on Nov 29, 2024
  5. metcoder95
    added a commit that references this issue on Nov 29, 2024

    fix(#3901): migrate dns interceptor to new hooks (#3903)

    fb3138d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.