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

In what cases would give out the [Maximum call stack size exceeded] error? #399

Closed
xidui opened this issue Jun 12, 2016 · 4 comments · Fixed by #447
Closed

In what cases would give out the [Maximum call stack size exceeded] error? #399

xidui opened this issue Jun 12, 2016 · 4 comments · Fixed by #447

Comments

@xidui
Copy link

xidui commented Jun 12, 2016

RangeError: Maximum call stack size exceeded
at Socket.flush (/Users/xidui/Documents/xidui/github/NodeBB/node_modules/engine.io/lib/socket.js:413:32)
at emitNone (events.js:85:20)
at WebSocket.emit (events.js:179:7)
at Array. (/Users/xidui/Documents/xidui/github/NodeBB/node_modules/engine.io/lib/transports/websocket.js:109:14)
at _stream_writable.js:383:15
at afterWrite (_stream_writable.js:346:3)
at onwrite (_stream_writable.js:337:7)
at Socket.WritableState.onwrite (_stream_writable.js:89:5)
at WriteWrap.afterWrite (net.js:775:12)
RangeError: Maximum call stack size exceeded
at Socket.flush (/Users/xidui/Documents/xidui/github/NodeBB/node_modules/engine.io/lib/socket.js:413:32)
at emitNone (events.js:85:20)
at WebSocket.emit (events.js:179:7)
at Array. (/Users/xidui/Documents/xidui/github/NodeBB/node_modules/engine.io/lib/transports/websocket.js:109:14)
at _stream_writable.js:383:15
at afterWrite (_stream_writable.js:346:3)
at onwrite (_stream_writable.js:337:7)
at Socket.WritableState.onwrite (_stream_writable.js:89:5)
at WriteWrap.afterWrite (net.js:775:12)

@JoneXie1986
Copy link

JoneXie1986 commented Jul 1, 2016

me too
socket.io 1.4.6

RangeError: Maximum call stack size exceeded
at Socket.flush (/data/system/ws-cluster/node_modules/socket.io/node_modules/engine.io/lib/socket.js:413:32)
at Socket.sendPacket (/data/system/ws-cluster/node_modules/socket.io/node_modules/engine.io/lib/socket.js:392:10)
at Socket.send.Socket.write (/data/system/ws-cluster/node_modules/socket.io/node_modules/engine.io/lib/socket.js:353:8)
at writeToEngine (/data/system/ws-cluster/node_modules/socket.io/lib/client.js:148:17)
at /data/system/ws-cluster/node_modules/socket.io/lib/client.js:156:9
at Encoder.encode (/data/system/ws-cluster/node_modules/socket.io/node_modules/socket.io-parser/index.js:135:5)
at Client.packet (/data/system/ws-cluster/node_modules/socket.io/lib/client.js:155:20)
at Socket.packet (/data/system/ws-cluster/node_modules/socket.io/lib/socket.js:210:15)
at Socket.emit (/data/system/ws-cluster/node_modules/socket.io/lib/socket.js:155:12)

@skywind0218
Copy link

skywind0218 commented Jul 8, 2016

me too
socket.io 1.4.8

/node_modules/engine.io/lib/socket.js:338
this.sentCallbackFn.push.apply(this.sentCallbackFn, this.packetsFn);
^
RangeError: Maximum call stack size exceeded
at Socket.flush (/home/gzliuhaiping/workspace/stf/stf-web/openstf/node_modules/engine.io/lib/socket.js:338:32)
at emitNone (events.js:72:20)
at WebSocket.emit (events.js:166:7)
at /home/gzliuhaiping/workspace/stf/stf-web/openstf/node_modules/engine.io/lib/transports/websocket.js:94:14
at afterWrite (_stream_writable.js:346:3)
at nextTickCallbackWithManyArgs (node.js:477:18)
at process._tickCallback (node.js:375:17)

@furiousOyster
Copy link

It seems that if you do not allow the main thread to take a break and process the queued up IO, then you will receive this error as the queues will overflow. If you break out of your current op, by calling setTimeout() or some other means to yield execution momentarily, the buffers will be cleared.
This seems to be self limiting, in that if allowing the IO to flush correctly, there is no amount of load that you can create which will cause stack size exceptions like these.

@darrachequesne
Copy link
Member

darrachequesne commented Oct 25, 2016

RangeError: Maximum call stack size exceeded can happen when the array this.packetsFn is too big (too many arguments):

[].push.apply([], new Array(200000));
// throws 'RangeError: Maximum call stack size exceeded'

If it is actually the reason, it can be fixed with a for loop:

this.sentCallbackFn.push.apply(this.sentCallbackFn, this.packetsFn);
// becomes
for (var i = 0; i < this.packetsFn.length; i++) {
  this.sentCallbackFn.push(this.packetsFn[i]);
};

Related: socketio/socket.io#2589

darrachequesne added a commit to darrachequesne/engine.io that referenced this issue Nov 20, 2016
Before that commit, undefined callbacks were also added to the array,
which could lead to 'Maximum call stack size exceeded' error when
flush() method was called.

Fixes socketio#399
darrachequesne added a commit that referenced this issue Nov 21, 2016
Before that commit, undefined callbacks were also added to the array,
which could lead to 'Maximum call stack size exceeded' error when
flush() method was called.

Fixes #399
darrachequesne pushed a commit that referenced this issue May 8, 2020
fix rejectUnauthorized bug
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

Successfully merging a pull request may close this issue.

5 participants