Skip to content

TypeError: this[#state].deleteRecord is not a function in builtin dns interceptor #3960

Closed

Description

@EAGzzyCSL

Bug Description

dns interceptor does not implements the deleteRecord function but used it,so a typeError will be triggered when ENOTFOUND.

I have searched the keyword deleteRecord but there is no any implements or type declare, maybe it's a dead code?

// undici source code lib/interceptor/dns.js:263

Image

Reproducible By

Reproducible code:

// undici version:latest,I used 7.1.1
const { Client, interceptors } = require('undici');
const { dns } = interceptors;

// x.y.z is a unavailable server
const client = new Client('http://x.y.z');

const dnsItp = dns({
  lookup(hostname, options, callback) {
    callback(null, [
      {
        address: '127.0.0.1',
        family: 4,
        ttl: 0,
      },
    ]);
  },
});

const client2 = client.compose(dnsItp);

(async () => {
  try {
    await client2.request({ path: '/', method: 'GET', origin: 'https://x.y.z' });
  } catch (e) {
    console.log('#error', e);
  }
})();

Expected Behavior

Catch error or request success, depends on the server in localhost.

Logs & Screenshots

Image
/private/var/folders/_c/nmt7v77j62749m7k6nr380_00000gq/T/tmp.yxci1cuDUW/node_modules/undici/lib/interceptor/dns.js:264
        this.#state.deleteRecord(this.#origin)
                    ^

TypeError: this[#state].deleteRecord is not a function
    at DNSDispatchHandler.onResponseError (/private/var/folders/_c/nmt7v77j62749m7k6nr380_00000gq/T/tmp.yxci1cuDUW/node_modules/undici/lib/interceptor/dns.js:264:21)
    at UnwrapHandler.onError (/private/var/folders/_c/nmt7v77j62749m7k6nr380_00000gq/T/tmp.yxci1cuDUW/node_modules/undici/lib/handler/unwrap-handler.js:94:36)
    at Request.onError (/private/var/folders/_c/nmt7v77j62749m7k6nr380_00000gq/T/tmp.yxci1cuDUW/node_modules/undici/lib/core/request.js:301:27)
    at Object.errorRequest (/private/var/folders/_c/nmt7v77j62749m7k6nr380_00000gq/T/tmp.yxci1cuDUW/node_modules/undici/lib/core/util.js:828:13)
    at onError (/private/var/folders/_c/nmt7v77j62749m7k6nr380_00000gq/T/tmp.yxci1cuDUW/node_modules/undici/lib/dispatcher/client.js:371:12)
    at connect (/private/var/folders/_c/nmt7v77j62749m7k6nr380_00000gq/T/tmp.yxci1cuDUW/node_modules/undici/lib/dispatcher/client.js:502:7)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
Emitted 'error' event on Client instance at:
    at Object.errorRequest (/private/var/folders/_c/nmt7v77j62749m7k6nr380_00000gq/T/tmp.yxci1cuDUW/node_modules/undici/lib/core/util.js:831:12)
    at onError (/private/var/folders/_c/nmt7v77j62749m7k6nr380_00000gq/T/tmp.yxci1cuDUW/node_modules/undici/lib/dispatcher/client.js:371:12)
    at connect (/private/var/folders/_c/nmt7v77j62749m7k6nr380_00000gq/T/tmp.yxci1cuDUW/node_modules/undici/lib/dispatcher/client.js:502:7)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

Environment

  • Node.js v22.11.0
  • MacOS 15.2 with Apple Silicon M3

Additional context

Activity

  1. changed the title [-]TypeError: this[#state].deleteRecord is not a function[/-] [+]TypeError: this[#state].deleteRecord is not a function in builtin dns interceptor[/+] on Dec 18, 2024
  2. metcoder95 commented on Dec 18, 2024

    @metcoder95
    Member

    Closed by #3958

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