Closed mattsalt closed 8 years ago
Oh and just wanted to say a huge thank you. This has saved me hours and hours of pain at work!
Hi Matthew,
Glad to hear its saved you some time :). Sorry it took me so long to check this out I've been swamped.
Looks like a stupid error on my part in the java I should be returning the response message but instead I just print out sql error to stdout. This is why the javascript doesn't remove the message because it doesn't know which message its for. Instead it returns an error to each callback currently in the messages map. It would be better to remove each of the messages at that point just to keep the map clean but even better would be to always return the message id so that you only return the error to the callback that caused it.
I would recommend using odbc lib and installing tds if its an option the performance and reliability will be MUCH better. I'll try and update it soon but it might be a little while...
Cheers Rod
On 17 March 2016 at 08:13, Matthew Salt notifications@github.com wrote:
Oh and just wanted to say a huge thank you. This has saved me hours and hours of pain at work!
— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/rodhoward/node-sybase/issues/1#issuecomment-197551507
Hi Rod,
No worries!
I have a fix in my fork that works for me by removing the messages then. If I get time I may take a look into the jar and see if I can update the message id. That does sound like a better solution.
Cheers, Matt
Hi Matt,
I have finally got back into this project and fixed up the error handling. On the java side it now packages the error message with the response. This then allows the normal handler to parse the message and return an error just for that one call. I did also fix up the leek in the error handler but that shouldn't be getting hit now in normal work flow.
Cheers Rod
Smashing, thanks for updating this. I've had this running on a small CRUD since April and it's been working great. Cheers, Matt
Hi, I've noticed that when a query completes successfully the the current message is cleared out
line 103 of SybaseDB.js
delete this.currentMessages[jsonMsg.msgId];
but the onError function doesn't do this, it just executes the callback
for (var k in this.currentMessages){ if (this.currentMessages.hasOwnProperty(k)) { this.currentMessages[k].callback(error); }
I'm curious if this is by design as the messages will build up over time if enough errors get through validation?Thanks, Matt
Edit: just to add I came across this when testing the validation in my site and attempting to insert duplicate keys. The first error is fine. The second attempt always fails with the error " can't set headers after they are sent' but I also get two callbacks from sybase. The first works and the second is the one causing the error.
Adding
delete this.currentMessages[k];
to the onError fixes this. Happy to raise a pull request if this is actually a bug and not by design.