JavaScript stack problem (IE8 with node.js and

October 24, 2014 at 20:43:41
Specs: Windows 7
Hey all. I'm a bit stuck right now, and hoping someone can shed some light. I'm relatively new to sockets in general, but have been programming in javascript on and off for several years, although only about as deep as is necessary to accomplish the task at hand. As a result, my understanding of some of the concepts surrounding the javascript stack heap, and sockets in general are somewhat limited.

Ok Here's the situation:

I've created an application intended to simply increment a counter, on several machines. Several users can click the "next" button and it will update instantly on all machines.
When you first connect, it retrieves the current number, and spits it out locally.

I've created the server here:

var io = require("");
var sockets = io.listen(8000);
var currentlyServing=0;
sockets.on("connection", function (socket)
console.log("client connected");
socket.emit("receive", currentlyServing);
socket.on("update", function(serving)
socket.broadcast.emit("receive", currentlyServing);
console.log("update received: "+currentlyServing);

console.log("Server Started");


Here is the relevant (I hope) excerpt from the client side:
var socket = io.connect("http://myhost:8000");

//function to update the page when a new update is received
socket.on("receive", function(receivedServing)
document.getElementById('msgs').value=""+String("00" + receivedServing).slice(-2);

//this is called in an onClick event in the HTML source
//sends the new number to all other stations except this one (handled by server side)
function nextServing()
var sendServing = parseInt(document.getElementById('nowServing').value)+1;
socket.emit("update", sendServing);
document.getElementById('msgs').value=""+String("00" + sendServing).slice(-2);

Ok so here's my problem. This runs absolutely fine in every system I've put it in, smoothly and beautifully - except for IE8. If left alone for more than 2-3 minutes (with no activity at all), I eventually receive a "stack overflow" error. The line number it appears on fluctuates (haven't determined the factors involved yet), but it always happens at that interval. On some workstations it takes longer, which I'm beginning to think has a direct correlation to the amount of phsyical RAM the machine has, or at least how much is being allocated to the web browser.

I found an online function to determine "max stack size", which I realize is not an exact science, however I did consistently get a number in the area of 3000. On my IE11 machine with considerable more resources, I found it to be in the area of 20,000. This may not be relevant, but I figured the more info the better :)

To avoid this problem for now so that the end users don't see this error message, I've take the entire client script, and put it into an iFrame which reloads itself every 60 seconds,essentially resetting the stack, which feels so dirty sitting so close to a web socket, but has bought me the time to post here. I've googled until I can't google any more, but when you search "node.js" or "" along with "stack overflow" on google, you just get a lot of posts about the two topics that are hosted on the stackoverflow dot com website. ARG lol


See More: JavaScript stack problem (IE8 with node.js and

October 27, 2014 at 08:52:33
Nobody has any node.js or socket experience?

Report •
Related Solutions

Ask Question