Run Cloudflare-style Durable Objects on top of goja and xgoja.
go-go-objects runs Durable Objects-style JavaScript actors inside Go. Each live object owns one goja runtime instance, a SQLite-backed storage namespace, and an HTTP gateway for RPC and fetch-style requests.
Use the standalone binary for local development and smoke testing. Use the xgoja provider when you want Durable Objects embedded into a generated Go/JavaScript host with other xgoja modules.
The default command starts an HTTP gateway with a built-in counter object when no bundle is supplied.
go-go-objects --addr 127.0.0.1:8787 --storage ./var/durable-objects
Increment the counter through RPC:
curl -X POST http://127.0.0.1:8787/rpc/COUNTER/global/increment \
-H 'content-type: application/json' \
-d '[1]'
Read the counter through fetch routing:
curl http://127.0.0.1:8787/fetch/COUNTER/global/count
Provide a CommonJS bundle that exports object classes through exports.objects.
go-go-objects \
--addr 127.0.0.1:8787 \
--storage ./var/durable-objects \
--bundle ./objects.js
If no manifest is supplied, namespaces are derived from exports.objects class names. For example, Counter becomes COUNTER and ChatRoom becomes CHAT_ROOM.
Use --manifest only when you need explicit namespace-to-class mappings.
objects:
COUNTER: Counter
ROOMS: ChatRoom
The runtime uses one actor per object identity. Dispatches to the same object are serialized across JavaScript invocation, Promise settlement, and result conversion. This preserves single-object semantics even when handlers are async.
SQLite storage is synchronous from JavaScript. Alarms and idle eviction are implemented by Go background loops that dispatch back into the same actor runtime.
| Problem | Cause | Solution |
|---|---|---|
unknown durable object namespace | The namespace is not in the manifest and could not be derived from exports.objects. | Check your export name or add a manifest entry. |
| Request returns 504 | The JavaScript dispatch exceeded --cpu-timeout, including Promise settlement time. | Increase --cpu-timeout or fix the handler to settle. |
| Storage appears empty | The object identity or --storage path changed. | Reuse the same namespace, object name, and storage root. |
| Manifest without bundle fails | A manifest maps namespaces to classes, but classes are loaded from a bundle. | Supply --bundle together with --manifest. |
go-go-objects-js-apigo-go-objects-xgoja-provider