Skip to content

Buffer and issues preventing to run Colyseus in webcontainer-core #1813

@endel

Description

@endel

Describe the bug

Hi there,

After issue #1182 has been fixed by @SamVerschueren (thank you!), I'd like to share other small issues that are now blocking to run Colyseus inside Stackblitz.

  1. We include @pm2/io as a dependency (popular Node.js library with +1M downloads). I had to do the following workaround to prevent crashes due to including @pm2/io:
const _getActiveRequests = process._getActiveRequests;
process._getActiveRequests = function (...args) { return _getActiveRequests(...args) || []; };
const _getActiveHandles = process._getActiveHandles;
process._getActiveHandles = function (...args) { return _getActiveHandles(...args) || []; };
  1. It seems there's some issue handling Buffers in webcontainer-core. In order to allow connecting a client with the server, I had to increase the maxPayload of ws package from 8192 to 16384.

  2. After connecting a client with the server, when trying to send a message, we get the following error:

Error: Data read, but end of buffer not reached {}
    at checkedRead (file:///home/projects/colyseus-app/node_modules/@colyseus/msgpackr/unpack.js:258:10)
    at Module.unpack (file:///home/projects/colyseus-app/node_modules/@colyseus/msgpackr/unpack.js:146:10)
    at MyRoom._onMessage (file:///home/projects/colyseus-app/node_modules/@colyseus/core/build/Room.mjs:721:70)
    at WebSocket.emit (node:events:30:11034)
    at Receiver.receiverOnMessage (/home/projects/colyseus-app/node_modules/@colyseus/ws-transport/node_modules/ws/lib/websocket.js:1220:20)
    at Receiver.emit (node:events:30:11034)
    at Receiver.dataMessage (/home/projects/colyseus-app/node_modules/@colyseus/ws-transport/node_modules/ws/lib/receiver.js:569:14)
    at Receiver.getData (/home/projects/colyseus-app/node_modules/@colyseus/ws-transport/node_modules/ws/lib/receiver.js:496:10)
    at Receiver.startLoop (/home/projects/colyseus-app/node_modules/@colyseus/ws-transport/node_modules/ws/lib/receiver.js:167:16)
    at Receiver._write (/home/projects/colyseus-app/node_modules/@colyseus/ws-transport/node_modules/ws/lib/receiver.js:94:10)
uKRFHQiE5 left!

Link to the blitz that caused the error

https://stackblitz.com/edit/colyseus-app?file=WEBCONTAINER_CORE_WORKAROUNDS.md

Steps to reproduce

From the "playground" web interface:

  1. Click "Join or Create" to join a room
  2. In the "Inspect connection" panel, click to "Send message"

(See WEBCONTAINER_CORE_WORKAROUNDS.md file from provided example project )

Expected behavior

No errors should be observed from the server-side

Parity with Local

Screenshots

Image

Platform

Browser name  = Chrome
Full version  = 135.0.0.0
Major version = 135
navigator.appName = Netscape
navigator.userAgent = Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
performance.memory = {
  "totalJSHeapSize": 164488934,
  "usedJSHeapSize": 116168714,
  "jsHeapSizeLimit": 2248146944
}
Hash = d69c5f7b

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions