ladjs / superagent

Ajax for Node.js and browsers (JS HTTP client). Maintained for @forwardemail, @ladjs, @spamscanner, @breejs, @cabinjs, and @lassjs.
https://ladjs.github.io/superagent/
MIT License
16.58k stars 1.33k forks source link

TypeError [ERR_INVALID_ARG_TYPE]: The "options.lookup" property must be of type function. Received null #1673

Closed thep0y closed 2 years ago

thep0y commented 2 years ago
OS: Windows 10 21H2 19044.1469
superagent: 7.1.0

package.json

{
  ...
  "dependencies": {
    "superagent": "^7.1.0"
  },
  ...
}

test.js

const { get } = require('superagent')

get("http://www.baidu.com", (err, res) => {
  if (err) throw err
  console.log(res.statusCode)
})

output:

$ node .\test.js                                                                                ─╯
node:internal/validators:237
    throw new ERR_INVALID_ARG_TYPE(name, 'Function', value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "options.lookup" property must be of type function. Received null
    at lookupAndConnect (node:net:1032:5)
    at Socket.connect (node:net:989:5)
    at Agent.connect [as createConnection] (node:net:203:17)
    at Agent.createSocket (node:_http_agent:341:26)
    at Agent.addRequest (node:_http_agent:292:10)
    at new ClientRequest (node:_http_client:305:16)
    at Object.request (node:http:96:10)
    at Request.request (K:\git\live-stream\node_modules\superagent\lib\node\index.js:833:18)
    at Request.end (K:\git\live-stream\node_modules\superagent\lib\node\index.js:989:8)
    at request.<computed> (K:\git\live-stream\node_modules\superagent\lib\node\index.js:1371:24) {
  code: 'ERR_INVALID_ARG_TYPE'
}

After downgrading to 6.1.0 there is no such issue:

$ node .\test.js
200
niftylettuce commented 2 years ago

Thanks, just deprecated that latest release. Must have missed it in the tests. Will revert that commit and publish new version probably or try to fix per #1595

apollyon600 commented 2 years ago

This just all of a sudden popped up as an error, I thought it was something I did but it turns out it was an internal error. Spent the last 2 hours trying to figure out why this was happening.. (sadge)

Pre "options.lookup" error version: npm i superagent@7.0.2

alalaha commented 2 years ago

oh man, fix this for the love of god it's giving me a big headache

(or revert update to stable version until you fix it) there are many packages dependent on this

bizob2828 commented 2 years ago

Thanks, just deprecated that latest release. Must have missed it in the tests. Will revert that commit and publish new version probably or try to fix per #1595

Thanks for deprecating @niftylettuce. Just FYI deprecating a package is nice because it provided a link to this but you also need to tag the previous released version(7.0.2) as latest, otherwise you'll still get 7.1.0 installed.

niftylettuce commented 2 years ago

v7.1.1 published

https://github.com/visionmedia/superagent/releases/tag/v7.1.1

adamkdean commented 2 years ago

Thank goodness for this. I've been racking my brain trying to work out what's going on today, where using a local version of a package was fine but the npm version was failing. Was just about to give up when I saw the npm WARN.