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

Sometimes timings.phases.dns is not lookup duration #35

Open
Motiveko opened this issue Oct 23, 2023 · 1 comment
Open

Sometimes timings.phases.dns is not lookup duration #35

Motiveko opened this issue Oct 23, 2023 · 1 comment

Comments

@Motiveko
Copy link

Motiveko commented Oct 23, 2023

I use got http client and I use option {dnsCache: true}.

In http-timer packages, theres's two code to calculate dns duration.

  1. on socket's lookup event listener

    const lookupListener = (): void => {
    timings.lookup = Date.now();
    timings.phases.dns = timings.lookup - timings.socket!;
    };
    socket.prependOnceListener('lookup', lookupListener);

  2. deferToConnect()'s connect callback function

    http-timer/source/index.ts

    Lines 102 to 110 in 62f6b38

    timings.connect = Date.now();
    if (timings.lookup === undefined) {
    socket.removeListener('lookup', lookupListener);
    timings.lookup = timings.connect;
    timings.phases.dns = timings.lookup - timings.socket!;
    }
    timings.phases.tcp = timings.connect - timings.lookup;

When use got with dnsCache, once hostname resolved, then until ttl, no lookup event emitted on the socket, so lookup time should be 0.

But above the code 2, dns never be 0 but tcp(connection time) will be 0.

When Server got a lot of traffic and got's socket connection delayed, value of tcp will not increased ( this always be 0 ), but value of dns increased.

I think this is causing confusion and needs to be fixed

@Motiveko Motiveko changed the title Sometimes timings.phases.dns is not looup duration Sometimes timings.phases.dns is not lookup duration Oct 23, 2023
@MartinKolarik
Copy link

This is also a problem when the request is made directly to an IP. There's obviously no DNS resolution in that case, but the timings report it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants