Error loading Scripts

I am having a problem with the networking of the project here: I have successfully gotten networking with building blocks to work, but now when I try to destroy blocks using the same networking method I get this error in the browser console:

Uncaught RangeError: Maximum call stack size exceeded
at t (
at t (
at t (
at t (
at t (
at t (
at t (
at t (
at t (
at t (
The all shows the link to here:

Here is my code for networking client side:

    var Network = pc.createScript('network');
    // static variables = null;
    Network.socket = null;
    // initialize code called once per entity
    Network.prototype.initialize = function() {
    var socket = io.connect(''); // Glitch hosted server
    Network.socket = socket;
    var onPlayerBuildN = function(name, x, y, z, tagero){
        //always directly after socket declairation
        socket.emit('otherBuild', {Name:name, X:x, Y:y, Z:z, Tagero:tagero});
    var onPlayerDestroy = function(destName){
        socket.emit('otherDestroy', destName);
    };"player:build", onPlayerBuildN);"blockDestroyed", onPlayerDestroy);
    socket.on('buildFromOther', function(data){"player:build2", data.Oname, data.Ox, data.Oy, data.Oz, data.Otagero);
    socket.on('destroyFromOther', function(car){"player:destroy", car.destName);

Here is my code for networking server side:

    var server = require('http').createServer();
    var options = {
        cors: true
    var io = require('')(server, options);

    io.sockets.on('connection', function(socket) {
            socket.on('otherBuild', function(data){
              socket.broadcast.emit('buildFromOther',        {Oname:data.Name,Ox:data.X,Oy:data.Y,Oz:data.Z,Otagero:data.Tagero});
              //console.log(data.X + ", " + data.Y + " ," + data.Z);
            socket.on('otherDestroy', function(car){
              socket.broadcast.emit('destroyFromOther', car.destName);

    console.log ('Server started');

Here is the link for my server:!/chicken64?path=server.js%3A20%3A20

Any ideas on how to fix this?

Hi @Nathan_Crouch,

I think the way your networking works when destroying a cube creates a circular reference.

  1. You send otherDestroy to the server.
  2. Then you broadcast to everybody destroyFromOther.
  3. The player that sends the initial otherDestroy receives that message and fires player:destroy again.

If that’s the case, the only thing you need to do is to make sure that on step 2. you broadcast the message to all players except the original player that initiated the action.

1 Like

Hi @Leonidas ! Thanks for answering, but I am 90% sure that socket.broadcast.emit sends to everyone but the sender in step 2, and socket.emit sends to everyone. Your point about step 2 is why I put the .broadcast part in the server code, but this may not be working or the problem may be somewhere else.

1 Like

@yaustar Do you have any ideas?

I’m afraid I don’t have the time to debug the project. I agree with Leonidas that it looks like an infinite loop somewhere.