creationix / postgres-js

The postgres backend protocol implemented in pure JS for use with node.js
122 stars 26 forks source link

TypeError: Bad argument at CheckInput #4

Open kldavis4 opened 14 years ago

kldavis4 commented 14 years ago

I am having a problem reading data from a database. The table is just a date field and a string field with a JSON object in it. Depending on the date range I select the query returns the data correctly OR I get this error:

/Users/kldavis/.node_libraries/postgres-js/postgres-pure.js:283 var message = first.slice(5, 5 + length); ^ TypeError: Bad argument. at checkInput (/Users/kldavis/.node_libraries/postgres-js/postgres-pure.js:283:25) at checkInput (/Users/kldavis/.node_libraries/postgres-js/postgres-pure.js:301:5) at checkInput (/Users/kldavis/.node_libraries/postgres-js/postgres-pure.js:301:5) at checkInput (/Users/kldavis/.node_libraries/postgres-js/postgres-pure.js:301:5) at checkInput (/Users/kldavis/.node_libraries/postgres-js/postgres-pure.js:301:5) at checkInput (/Users/kldavis/.node_libraries/postgres-js/postgres-pure.js:301:5) at checkInput (/Users/kldavis/.node_libraries/postgres-js/postgres-pure.js:301:5) at checkInput (/Users/kldavis/.node_libraries/postgres-js/postgres-pure.js:301:5) at checkInput (/Users/kldavis/.node_libraries/postgres-js/postgres-pure.js:301:5) at checkInput (/Users/kldavis/.node_libraries/postgres-js/postgres-pure.js:301:5)

I did a little bit of debugging and determined that the call 'int32read(1)' is returning NaN in this line:

function checkInput() { if (queue.length === 0) { return; } var first = queue[0]; var code = String.fromCharCode(first[0]);

var length = first.int32Read(1) - 4; <

I can possibly do some more work trying to figure what in the data is causing this to break, but there probably also needs to be a fix in checkInput to make it a little more robust.

pdelanauze commented 14 years ago

Same. Was able to reproduce this with 0.1.0 tag