Script errors and logging
What happens after an error
Section titled “What happens after an error”| Where it happens | Behavior |
|---|---|
| Uncaught exception or unhandled Promise rejection on the server | With the default Node.js error handling, the server exits with code 1. This includes failures in event listeners. |
Client startup, including imports and top-level await |
Client startup fails and the loading screen displays an error. |
| Client event, timer or frame callback | The error is logged. The failed callback ends, and other script work continues. Recurring callbacks remain registered. |
| Unhandled Promise rejection in a running client script | The rejection is logged, and the script continues running. |
A request handler’s exception or rejected Promise is sent to the caller as a rejection. See Request errors for the messages and timeout behavior.
Handle failures where they occur
Section titled “Handle failures where they occur”Put try/catch inside an asynchronous event or timer callback, around the work
it awaits. Handle the failure there by reporting it to the player, restoring the
feature’s state or scheduling a retry when repeating the operation is safe.
Changes made before an exception remain applied. If an error leaves server
state uncertain, use graceful shutdown
and the service’s restart policy. A global
uncaughtException handler that logs and continues can leave that state
in use.
A failing client frame callback can write the same error every frame. Remove the callback when disabling the affected feature, using the handle returned by the scheduler.
Keep the stack trace
Section titled “Keep the stack trace”Both client and server scripts provide revo.log(). Its arguments are converted
to strings. Pass the error’s stack explicitly to include the call stack:
// @ts-check/// <reference types="@revomp/types-client" />
import * as revo from 'revo-client';
/** * @param {string} operation * @param {unknown} error */function logFailure(operation, error) { const details = error instanceof Error ? error.stack ?? error.message : String(error);
revo.log(`[${operation}] ${details}`);}Call logFailure(operation, error) from a catch block. Choose an operation name
such as inventory:save, and include relevant player or entity IDs when they
help identify the failing action. The same function works on the server with
an import from revo-server.
Logging at the point that handles the failure keeps the operation context and avoids repeating the same error at each call level.
Find the output
Section titled “Find the output”Development logs covers the server terminal, client log files and in-game console. Server monitoring covers file retention and capturing Node.js standard output and error.
For errors in a WebView page, inspect that page’s Console through CEF debugging.