eelcocramer / node-gpsd

Node.js gpsd client for GPS tracking device.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

backtrace due to last fix

mhaberler opened this issue · comments

unfortunately I receive this when using node-red-contrib-gpsd which now pulls in 0.3.3:

Exception has occurred: TypeError: The "list[0]" argument must be an instance of Buffer or Uint8Array. Received type string ('{"class":"SKY","device":...)
  at new NodeError (node:internal/errors:393:5)
    at Function.concat (node:buffer:565:13)
    at Socket.<anonymous> (/Users/mah/.node-red/node_modules/node-gpsd/lib/gpsd.js:47:55)
    at Socket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:293:11)
    at Socket.Readable.push (node:internal/streams/readable:234:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
    at TCP.callbackTrampoline (node:internal/async_hooks:130:17)
commented

Thanks for reporting. What version of node are you using?

I've created a patch in branch 'issue-22'. Are you in a position to test that fix?

https://github.com/eelcocramer/node-gpsd/tree/issue-22

node v16.15.1, MacOS

yes, will give it a spin and report! thanks!

buf is not visible in line 53:

image

move up the buf declaration to line 39 and this works for me:

    sock.on("data", function (payload) {
        const buf = Buffer.from(payload, "utf-8");
        if (payload[payload.length - 1] === '\n') {
commented

Thanks for pointing that out.

I just published v0.3.4, including a fixed for the issue above, on npm

verified to work!
I'll notify the owner of https://github.com/damoclark/node-red-contrib-gpsd to bump the node-gpsd version number

thanks!