Summary
During normal Unity Play/Stop cycles, the monitor WebSocket can close with code 1006.
The middleware currently handles close codes 1006 and 1009 in the same way and displays:
[ERR 1006] Message too big!
Message: ArrayBuffer {
(detached),
[byteLength]: 0
}
Message size: 45 bytes
This message is misleading because:
1006 means an abnormal WebSocket closure.
1009 is the actual code for a message that is too large.
- The reported message was only 45 bytes.
- The raw
ArrayBuffer is already detached when it is displayed.
The error is visible even with:
VERBOSE=false
EXTRA_VERBOSE=false
Steps to reproduce
- Start GAMA.
- Start the SIMPLE webplatform.
- Start Unity Play Mode.
- Wait approximately 20 seconds.
- Stop Unity Play Mode.
- Wait approximately 10 seconds.
- Repeat the Play/Stop cycle.
Actual behavior
The middleware displays:
[ERR 1006] Message too big!
ArrayBuffer {
(detached),
[byteLength]: 0
}
Message size: 45 bytes
Expected behavior
- Handle code
1006 separately from 1009.
- Do not display
Message too big for code 1006.
- Do not log the raw
ArrayBuffer.
- Keep normal Unity Play/Stop monitor closures out of non-verbose error logs.
- Continue displaying a real error for code
1009.
Local validation
To test a possible solution before opening this issue, I created a local branch of the webplatform:
test/monitor-close-logging
I modified the monitor WebSocket close-handling logic in MonitorServer.ts in order to test whether these misleading errors could be removed without affecting the normal Unity Play/Stop workflow.
The local changes were limited to the monitor close handler:
- the close reason and message size are copied immediately inside the WebSocket callback;
- close code
1006 is handled separately from 1009;
- code
1006 is logged at debug level instead of being reported as Message too big;
- code
1009 remains the actual oversized-message error;
- the raw
ArrayBuffer is no longer passed directly to the logger.
After applying these changes, I repeated the same Unity Play/Stop scenario twice.
The following messages no longer appeared:
ERR 1006
Message too big
ArrayBuffer
detached
Message size
The test therefore suggests that separating 1006 from 1009 and copying the close data immediately is enough to remove this misleading error spam from normal logs.
Suggested fix
A potential fix for this issue could follow this approach:
- In
MonitorServer.ts, copy the close reason and byte length immediately at the beginning of the WebSocket close callback.
- Handle close code
1006 in its own case.
- Do not label code
1006 as Message too big.
- Log expected short-lived
1006 monitor closures at debug level, so they do not appear when verbose logging is disabled.
- Keep code
1009 as the real oversized-message error.
- Avoid logging the raw uWebSockets.js
ArrayBuffer, because it may already be detached when the logger formats it.
- Add or update tests to verify that:
- a
1006 closure does not produce a Message too big error;
- a real
1009 closure still produces an oversized-message error;
- normal Unity Play/Stop cycles do not emit detached-buffer logs.
Other PlayerManager warnings still appear during the same Play/Stop workflow. They are separate from this monitor logging issue and were intentionally not modified during this local test.
Summary
During normal Unity Play/Stop cycles, the monitor WebSocket can close with code
1006.The middleware currently handles close codes
1006and1009in the same way and displays:This message is misleading because:
1006means an abnormal WebSocket closure.1009is the actual code for a message that is too large.ArrayBufferis already detached when it is displayed.The error is visible even with:
VERBOSE=false
EXTRA_VERBOSE=false
Steps to reproduce
Actual behavior
The middleware displays:
Expected behavior
1006separately from1009.Message too bigfor code1006.ArrayBuffer.1009.Local validation
To test a possible solution before opening this issue, I created a local branch of the webplatform:
test/monitor-close-logging
I modified the monitor WebSocket close-handling logic in
MonitorServer.tsin order to test whether these misleading errors could be removed without affecting the normal Unity Play/Stop workflow.The local changes were limited to the monitor close handler:
1006is handled separately from1009;1006is logged at debug level instead of being reported asMessage too big;1009remains the actual oversized-message error;ArrayBufferis no longer passed directly to the logger.After applying these changes, I repeated the same Unity Play/Stop scenario twice.
The following messages no longer appeared:
The test therefore suggests that separating
1006from1009and copying the close data immediately is enough to remove this misleading error spam from normal logs.Suggested fix
A potential fix for this issue could follow this approach:
MonitorServer.ts, copy the close reason and byte length immediately at the beginning of the WebSocket close callback.1006in its own case.1006asMessage too big.1006monitor closures at debug level, so they do not appear when verbose logging is disabled.1009as the real oversized-message error.ArrayBuffer, because it may already be detached when the logger formats it.1006closure does not produce aMessage too bigerror;1009closure still produces an oversized-message error;Other
PlayerManagerwarnings still appear during the same Play/Stop workflow. They are separate from this monitor logging issue and were intentionally not modified during this local test.