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

exception in xhr-multipart.js (in 0.6.17) when client.send() is called #189

Closed
gkostov opened this issue Apr 14, 2011 · 5 comments
Closed

Comments

@gkostov
Copy link

gkostov commented Apr 14, 2011

Yesterday we updated to 0.6.17 and those exceptions started to pop:
TypeError: Cannot call method 'write' of null
at [object Object]._write (/root/root/.npm/socket.io/0.6.17/package/lib/socket.io/transports/xhr-multipart.js:64:19)
at [object Object].send (/root/root/.npm/socket.io/0.6.17/package/lib/socket.io/client.js:32:8)
at ....
The code that throws it is:
63: this.response.write("Content-Type: text/plain" + (message.length === 1 && message.charCodeAt(0) === 6 ? "; charset=us-ascii" : "") + "\n\n");
64: this.response.write(message + "\n"); // this throws the exception because this.response is null !?!?

so appears that somehow the "response" property is null on line 64 but has been still there on line 63.
I'm trying to figure out when exactly it happens and if this may be due to a fault on our other code but so far it does not seem so. On the next fail I'll have a print of the "message" to check if that may have gone terribly wrong (a simple object is passed to .send() so should be nothing unusual).

@gkostov
Copy link
Author

gkostov commented Apr 17, 2011

That just happened again. But this time appears that the call was initiated by a timer (most likely created by the library) and did not go through my code. This is the full stack trace of the call which happens to be sending a hartbeat message:
TypeError: Cannot call method 'write' of null
at [object Object]._write (/root/root/.npm/socket.io/0.6.17/package/lib/socket.io/transports/xhr-multipart.js:64:19)
at [object Object].send (/root/root/.npm/socket.io/0.6.17/package/lib/socket.io/client.js:32:8)
at Object. (/root/root/.npm/socket.io/0.6.17/package/lib/socket.io/client.js:126:10)
at Timer.callback (timers.js:83:39)

@japostoles
Copy link

We are seeing this issue as well. The object exists at the point of the if conditional (line 62) but appears to be null after the first write. I think the response is getting deallocated, possibly due to the behavior of response.write as noted in the node documentation:

"The first time response.write() is called, it will send the buffered header information and the first body to the client. The second time response.write() is called, Node assumes you're going to be streaming data, and sends that separately. That is, the response is buffered up to the first chunk of body."

One thing to note, we ONLY see this behavior when using https.. it seems to work fine over http.

@pete001
Copy link

pete001 commented May 19, 2011

I can confirm that this issue still persists in 0.6.18. Very interesting that this is potentially a HTTPS only issue - we are finding this error in HTTPS as well....

@gkostov
Copy link
Author

gkostov commented Jun 1, 2011

Do you think it is safe to ignore this exception? Will the library cleanup correctly and remain stable and working properly?

@smj10j
Copy link

smj10j commented Jun 7, 2011

I can reproduce this issue by setting up a standard node server and directly requesting the following URL:
https://localhost:25785/transaction/xhr-multipart

Where "25785" is the port and "transaction" is the resource.

Currently using the uncaught exception handler and things seem to be stable for a short-term fix:
process.on('uncaughtException', function (err) {
console.log('Caught exception: ' + err);
});

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

5 participants