I may have a configuration or versoin issue on my end, but figured I'd post and get some feedback.
Upgraded to pg 7.4.3. Running node version 8.11.2 at the moment. Connecting to postgres 9.6 with pg, server is rejecting the connection (I can see that in /var/log/postgresql/postgresql-9.6-main.log, but that's my own issue). The error I get in pg is:
MYPATH/nodejs/node_modules/pg/lib/connection.js:654
var end = buffer.indexOf(0, start)TypeError: Second argument must be a string or a buffer.
at Connection.parseCString (MYPATH/nodejs/node_modules/pg/lib/connection.js:654:21)
at Connection.parseE (MYPATH/nodejs/node_modules/pg/lib/connection.js:550:30)
at Connection.parseMessage (MYPATH/nodejs/node_modules/pg/lib/connection.js:378:19)
at Socket.(MYPATH/nodejs/node_modules/pg/lib/connection.js:119:22)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at Socket.Readable.push (_stream_readable.js:208:10)
at TCP.onread (net.js:597:20)
And this apparently can be addressed with a simple "\0" instead of 0 in connection.js:
Connection.prototype.parseCString = function (buffer) {
var start = this.offset
var end = buffer.indexOf('\0', start)
this.offset = end + 1
return buffer.toString(this.encoding, start, end)
}
Interested in submitting a PR w/ a test?
On Wed, Aug 15, 2018 at 3:53 PM mpekar notifications@github.com wrote:
I may have a configuration or versoin issue on my end, but figured I'd
post and get some feedback.Upgraded to pg 7.4.3. Running node version 8.11.2 at the moment.
Connecting to postgres 9.6 with pg, server is rejecting the connection (I
can see that in /var/log/postgresql/postgresql-9.6-main.log, but that's my
own issue). The error I get in pg is:MYPATH/nodejs/node_modules/pg/lib/connection.js:654
var end = buffer.indexOf(0, start)TypeError: Second argument must be a string or a buffer.
at Connection.parseCString
(MYPATH/nodejs/node_modules/pg/lib/connection.js:654:21)
at Connection.parseE
(MYPATH/nodejs/node_modules/pg/lib/connection.js:550:30)
at Connection.parseMessage
(MYPATH/nodejs/node_modules/pg/lib/connection.js:378:19)
at Socket. (MYPATH/nodejs/node_modules/pg/lib/connection.js:119:22)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at Socket.Readable.push (_stream_readable.js:208:10)
at TCP.onread (net.js:597:20)And this apparently can be addressed with a simple "\0" instead of 0 in
connection.js.—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/brianc/node-postgres/issues/1708, or mute the thread
https://github.com/notifications/unsubscribe-auth/AADDoVdx_160ExnyoZ9dUPMLy7zpVdcdks5uRIo7gaJpZM4V-yzP
.
Yeah I'm still digging a bit more though. I'm wondering if the issue has something to do with the fact that the error occurs before a connection is established. From what I've read on the Buffer class source code, using 0 instead of "\0" should be faster as long as it works properly, so I don't think the code for parseCString should be changed--probably something higher up the ladder.
It looks like that error comes from node-buffertools’s prototype extensions. (node-buffertools dates back to Node 0.3, when Buffer#indexOf didn’t exist.) You should find out what depends on buffertools and have it use the module’s exports instead of changing Buffer.prototype.
charmander that sounds quite plausible but I don't see node-buffertool under node_modules.
Two more factors:
1) I was using an older version of connect-session-knex that had slightly different connection params. I'm examining that now.
2) I'm using a "LOCAL" connection that was trying to reference "/var/run/postgresql" as the host. I may need to adjust to a newer config params format.
I'll revise or close this as soon as I find root cause.
Wait wait wait, ok I see "buffertools" here, sorry was looking for "node-buffertools". Thanks charmander!
Most helpful comment
It looks like that error comes from node-buffertools’s prototype extensions. (node-buffertools dates back to Node 0.3, when
Buffer#indexOfdidn’t exist.) You should find out what depends on buffertools and have it use the module’s exports instead of changingBuffer.prototype.