Skip to content
New issue

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

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

Already on GitHub? # to your account

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

Closed
EAGzzyCSL opened this issue Dec 18, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@EAGzzyCSL
Copy link

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

@EAGzzyCSL EAGzzyCSL added the bug Something isn't working label Dec 18, 2024
@EAGzzyCSL EAGzzyCSL changed the title TypeError: this[#state].deleteRecord is not a function TypeError: this[#state].deleteRecord is not a function in builtin dns interceptor Dec 18, 2024
@metcoder95
Copy link
Member

Closed by #3958

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants