Sitelet https://github.com/nodejs/node/issues/46919
Skip to content

Expect to expose getDefaultVerbatim method #46919

Description

@btea

What is the problem this feature will solve?

When the dnsOrder value of the dns module changes, I hope to get the modified value or judge that the value has changed. Therefore, I want to expose getDefaultVerbatim method or expose a new method getDefaultResultOrder.

function getDefaultVerbatim() {
return dnsOrder !== 'ipv4first';
}

function getDefaultResultOrder() {
  return dnsOrder;
}

What is the feature you are proposing to solve the problem?

Judging whether dnsOrder has changed according to the exposed api.

What alternatives have you considered?

No response

Activity

  1. bnoordhuis commented on Mar 4, 2023

    @bnoordhuis
    Member

    Can you explain why you want to know that? I'm trying to think of reasonable use cases but I'm coming up empty-handed.

    To a first approximation, as a library author, you're not expected to care. That's the responsibility of the application.

    As an application programmer, you normally configure it at startup and then never change nor care about it later.

  2. btea commented on Mar 4, 2023

    @btea
    ContributorAuthor

    After I start a node service, if I use getDefaultResultOrder to change the value of dnsOrder or change other contents of the same file, when hot update is triggered at this time, I hope to obtain the value before and after the change through the exposed method to judge whether the order value has changed.

    According to the results of the above judgment, I will decide whether to update the local value printed on the terminal.

  3. bnoordhuis commented on Mar 4, 2023

    @bnoordhuis
    Member

    Maybe I misunderstand you but that seems of really limited utility. Why would it matter if the value changed between reloads? Is it purely a diagnostic?

  4. btea commented on Mar 5, 2023

    @btea
    ContributorAuthor

    Yeah, the situation I am currently encountering is mainly to compare the values ​​before and after the change and make some changes.

    However, since the logic of changing the dnsOrder value is not in the same file as the logic that requires other processing, I think it would be convenient to dynamically obtain the values ​​before and after the change for comparison.

    In addition, it suddenly occurred to me that by comparing the results of dns.promises('localhost') and dns.promises('localhost', { verbatim: true }), it seems that it is possible to determine whether the value of dnsOrder has changed, but some cumbersome.

  5. bnoordhuis commented on Mar 5, 2023

    @bnoordhuis
    Member

    I understand what you're saying now but I don't know if it passes the bar for inclusion in the standard library. Can I suggest you open a pull request and see how it's received?

  6. tniessen commented on Mar 5, 2023

    @tniessen
    Member

    I agree with Ben; I think repeatedly switching between verbatim and ipv4first at runtime and being unable to communicate this change within the application is a very niche use case.

  7. btea commented on Mar 5, 2023

    @btea
    ContributorAuthor

    Do you mean to open a pull request to expose the getDefaultVerbatim method or expose a new method getDefaultResultOrder?

  8. bnoordhuis commented on Mar 6, 2023

    @bnoordhuis
    Member

    I'll leave that up to you. What you think is best.

  9. btea commented on Mar 6, 2023

    @btea
    ContributorAuthor

    Ok, I created a pr exposing the method getDefaultResultOrder. It looks like the docs also need to be updated.

  10. added a commit that references this issue on May 2, 2023
  11. added a commit that references this issue on Jul 6, 2023
  12. added a commit that references this issue on Jul 6, 2023
  13. moved this from Awaiting Triage to Done in Node.js feature requestson Jun 29, 2024
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

    feature requestIssues requesting new Node.js features.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions