Skip to content

Runtime and lifecycle

The server embeds Node.js 22 and loads <scripts_path>/server/main.js on its main scripting isolate. VIMP installs the server-shaped vimp global before evaluating that entry point.

Startup gate

Register handlers, initialize required services, and call vimp.markReady(). The network listener starts only after the first successful call. A second call returns false; failing to call it before script_ready_timeout_secs aborts startup.

ts
await connectDatabase()
registerGameplayHandlers()

if (!vimp.markReady()) {
  throw new Error('The gamemode was already marked ready')
}

Do not mark ready before dependencies required by connection handlers are available. Conversely, optional background work should not keep the startup gate closed.

Execution and failures

Server handlers run inside the main embedded Node isolate. Worker threads may perform independent CPU work, but the vimp global is not installed inside a worker. Pure JavaScript packages and standard Node modules work normally.

Server-side scripts are trusted code. An uncaught fatal error, a native addon crash, or memory corruption can terminate the whole server process. Supervise production servers externally and test native dependencies before deployment.

Client scripts are loaded after client resources and GTA asset metadata are prepared. Client timers return numeric identifiers, as declared by the client types.

VIMP developer documentation