go-go-objects overview

Run Cloudflare-style Durable Objects on top of goja and xgoja.

Sections

Terminology & Glossary
πŸ“– Documentation
Navigation
4 sectionsv0.1
πŸ“„ go-go-objects overview β€” glaze help go-go-objects-overview
go-go-objects-overview

go-go-objects overview

Run Cloudflare-style Durable Objects on top of goja and xgoja.

Appdurable-objectsgojaxgojasqlitehttpgo-go-objects

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.

Running the built-in counter

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

Running your own bundle

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

Runtime behavior

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.

Troubleshooting

ProblemCauseSolution
unknown durable object namespaceThe 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 504The JavaScript dispatch exceeded --cpu-timeout, including Promise settlement time.Increase --cpu-timeout or fix the handler to settle.
Storage appears emptyThe object identity or --storage path changed.Reuse the same namespace, object name, and storage root.
Manifest without bundle failsA manifest maps namespaces to classes, but classes are loaded from a bundle.Supply --bundle together with --manifest.

See also

  • go-go-objects-js-api
  • go-go-objects-xgoja-provider