Error codes
Errors reach clients as error messages or as failed result messages. Each has a code and a human-readable message.
Platform errors
| Code | Meaning |
|---|---|
INVALID_MESSAGE |
The message was not valid JSON or had the wrong shape. |
NOT_JOINED |
The client sent a message that needs a room before joining one. |
ALREADY_JOINED |
The connection already joined a room. |
ROOM_NOT_FOUND |
The room does not exist. |
JOIN_REJECTED |
The join was refused, for example an unknown project, an invalid API key or a plan limit. |
PROJECT_SUSPENDED |
The project is suspended. Connected players receive this and are disconnected. |
INVALID_ID |
A room or player ID used characters other than letters, numbers, underscores and hyphens, or was longer than 64 characters. |
PLAYER_ID_TAKEN |
That player ID is already in the room, from a different address. |
PLAYER_REPLACED |
Sent to an old connection when the same player ID reconnects from the same address. |
ROOM_FULL |
The room already has 100 players. |
RATE_LIMITED |
Too many messages, too many failed connection attempts, or the project is using too much compute. |
FUNCTION_NOT_FOUND |
No enabled Function has that name. |
FUNCTION_ERROR |
The Function failed with an unexpected error. |
INTERNAL_ERROR |
Something went wrong on the server. |
Function errors
Errors you throw with new NetStackError(code, message) reach the caller unchanged, so choose codes your game can act on.
The sandbox raises these when a Function breaks a limit:
| Code | Meaning |
|---|---|
TIMEOUT |
The Function used more than 150 ms of CPU time. |
OUT_OF_MEMORY |
The Function used more than 32 MB. |
STACK_OVERFLOW |
The Function recursed too deeply. |
BAD_KEY |
A property name was invalid or reserved. |
BAD_VALUE |
A value was not JSON-serializable, or undefined was written. |
VALUE_TOO_LARGE |
A value exceeded its size limit. |
TOO_MANY_WRITES |
More than 100 property writes in one call. |
TOO_MANY_BROADCASTS |
More than 50 broadcasts in one call. |
BAD_EVENT |
An event name was invalid. |
When a Function fails for any reason, none of its property changes or broadcasts are applied.
Save-time errors
The dashboard rejects a Function when it is saved if the code has a syntax error (reported with a line number), has no export default function, or uses import or additional export statements.