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

'Invalid URL' error message different in Node 18 #2107

Closed
2 tasks done
DanCurryy opened this issue Aug 12, 2022 · 4 comments
Closed
2 tasks done

'Invalid URL' error message different in Node 18 #2107

DanCurryy opened this issue Aug 12, 2022 · 4 comments

Comments

@DanCurryy
Copy link

Describe the bug

  • Node.js version: v18.7.0
  • OS & version: Mac OS Monterey 12.4

Actual behavior

Expected error.message to be of the form (as seen in node v14.17.6):
Invalid URL: invalid-url.com

Expected behavior

We receive an error message:
Invalid URL

Without the URL included in the message

Code to reproduce

async function test () {
  const { default: got } = await import('got')
  return got.get('invalid-url.com')
}

function main () {
  return test()
    .then(res => {
      console.log(res)
    })
    .catch(err => {
      console.log(err.message)
    })
}

main()

Checklist

  • I have read the documentation.
  • I have tried my code with the latest version of Node.js and Got.
@szmarczak
Copy link
Collaborator

The URL should be available under error.input. This is actually a Node.js issue, Got doesn't modify URL error messages.

@sindresorhus Do we want to change this?

@sindresorhus
Copy link
Owner

I think we should first try to get it fixed in Node.js

@DanCurryy
Copy link
Author

Found where the change was made - seems it was intentional and will not be getting
"fixed" as such: https://github.com/nodejs/node/blob/75b68c6e4db515f76df73af476eccf382bbcb00a/lib/internal/errors.js#L1363

As well as the following PR that introduced it, so will close this unless it's within the mandate for got to alter the error at all.

@sindresorhus
Copy link
Owner

Closing as the URL is available programmatically and the Node.js reasoning for hiding it makes sense.

@sindresorhus sindresorhus closed this as not planned Won't fix, can't repro, duplicate, stale Aug 30, 2022
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

3 participants