Skip to content

Debugging

Inspector

You can use the the built-in inspector from Node.js to debug your application.

Tip

Read more about Debugging Node.js Applications.

Using the inspector on production environment

Be careful when using the inspector on production. Using memory snapshots and breakpoints will impact the experience of your users directly.

1. Connect to the remote server:

ssh root@remote.example.com

2. Check the PID of the Node process

ps aux | grep node

3. Attach the inspector on the process

kill -usr1 PID

4. Create a SSH tunnel from your local machine to the remote inspector

ssh -L 9229:localhost:9229 root@remote.example.com

Your production server should now appear on chrome://inspect.

Debug messages

The server provides some debug messages that you can enable individually per category, by setting the DEBUG environment variable.

To enable all logs, you can run your server using:

DEBUG=colyseus:* node server.js

See below all available debug categories with sample outputs.

colyseus:patch

Logs the number of bytes and interval between patches broadcasted to all clients.

colyseus:patch "chat" (roomId: "ryWiL5rLTZ") is sending 28 bytes: +57ms

colyseus:errors

Logs whenever unexpected (or expected, internally) errors happens on the server-side.

colyseus:matchmaking

Logs whenever a room is spanwed or disposed.

colyseus:matchmaking spawning 'chat' on worker 77218 +52s
colyseus:matchmaking disposing 'chat' on worker 77218 +2s