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

TypeError [ERR_INVALID_ARG_TYPE] at logRequest(), app.js #35

Closed
hnakai0909 opened this issue Aug 23, 2021 · 4 comments
Closed

TypeError [ERR_INVALID_ARG_TYPE] at logRequest(), app.js #35

hnakai0909 opened this issue Aug 23, 2021 · 4 comments

Comments

@hnakai0909
Copy link
Contributor

hnakai0909 commented Aug 23, 2021

Problem:
./meross throws TypeError [ERR_INVALID_ARG_TYPE] and cannot see what the real error is,
when ./meross with -v option and situation that occuring some network error, such as reserving inappropriate IP address to --gateway option.

Log:
10.10.10.155 is not meaningful IP address example which not exist Meross device.

$ ./bin/meross info --gateway 10.10.10.155 -v
Getting info about device with IP 10.10.10.155
> POST /config
> Host: 10.10.10.155
> Accept: application/json, text/plain, */*
> Content-Type: application/json
>
{
  header: {
    from: '',
    method: 'GET',
    namespace: 'Appliance.System.All',
    messageId: '3d09087d7574042037eb832a3a3f8ff8',
    timestamp: 1629745262,
    sign: '3c699b7bae58b4b647e8864e6b1299ac'
  },
  payload: {}
}

node:internal/process/promises:227
          triggerUncaughtException(err, true /* fromPromise */);
          ^

TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:329:5)
    at validateString (node:internal/validators:129:11)
    at Url.parse (node:url:169:3)
    at Object.urlParse [as parse] (node:url:156:13)
    at new URL (/home/pi/Downloads/Meross/lib/api.js:6:35)
    at logRequest (/home/pi/Downloads/Meross/lib/api.js:62:15)
    at handleRequestError (/home/pi/Downloads/Meross/lib/api.js:99:13)
    at API.deviceInformation (/home/pi/Downloads/Meross/lib/api.js:205:13)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at async /home/pi/Downloads/Meross/bin/meross-info:42:5 {
  code: 'ERR_INVALID_ARG_TYPE'
}

My environment:
Hardware : Raspberry Pi 1 (Yes, it's old)

$ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
VERSION_CODENAME=stretch
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
$ node -v
v15.6.0
$ npm -v
7.21.0

Cause?:
In

let url = new URL(request.url);

, logRequest() fails if argument request does not contains url .

My workaround:
In

} else if (error.request) {

,Fix
} else if (error.request) {
to
} else if (error.request && error.request.url) {

Log with applying workaround:
Shows error normally (without TypeError).

$ ./bin/meross info --gateway 10.10.10.155 -v
Getting info about device with IP 10.10.10.155
> POST /config
> Host: 10.10.10.155
> Accept: application/json, text/plain, */*
> Content-Type: application/json
>
{
  header: {
    from: '',
    method: 'GET',
    namespace: 'Appliance.System.All',
    messageId: '848fbdb9951232b81a9f1d5858406023',
    timestamp: 1629746553,
    sign: '42006e85b09bf0d4da77427515cab7ff'
  },
  payload: {}
}

Error connect EHOSTUNREACH 10.10.10.155:80
@bytespider
Copy link
Owner

Well the true error is actually that the device you specified at 10.10.10.155 doesn't have the Meross HTTP API or doesn't exist. It's unusual for a Meross device to use anything but 10.10.10.1 except when it's connected to your WiFi.

@hnakai0909
Copy link
Contributor Author

I mean 10.10.10.155 is just one of the example to manually cause network-related error, so this address does not have meaning.

What I wanted to say is, when network-related error happens, some of that that does not contains url in error.request, the TypeError cause, and we cannot get what the real error is.

@hnakai0909
Copy link
Contributor Author

Related PR #36 issued.

@hnakai0909
Copy link
Contributor Author

Sorry, there are no need to add sudo, so I fixed logs.

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