Skip to main content

connect()

connect() constructs Pulse immediately and creates one background readiness promise. Use awaitConnection() during application startup to surface connection, permission, and index errors before accepting traffic.

Connection options

Strings must be non-empty. maxPoolSize must be a positive integer. Durations and worker counts must be finite positive numbers, except retention, retry counts, and retry delays may be zero where their types allow it. Retry settings are rejected when their largest computed delay falls outside MongoDB’s supported date range. Pulse sets the MongoDB driver’s maxPoolSize to 5 instead of its default of 100. minPoolSize remains at the driver default of 0, so the pool grows on demand. The limit applies to application connections in each server pool; the driver also opens monitoring connections for the MongoDB topology.
changeStreams has been removed and cannot be enabled or disabled. Pulse always uses polling and reconciliation. Remove the field from existing JavaScript and TypeScript configurations; providing it, even as changeStreams: 'disabled', makes connect() fail immediately with a PulseConfigurationError.

pulse.awaitConnection()

Resolves after the MongoDB client connects, the database is selected, and collections and indexes are ready. Workers start only after successful initialization. publish(), subscribe(), and history.find() call it internally.

pulse.publish()

Returns:
The event _id is a UUIDv7 string. Pulse never uses MongoDB ObjectId for its own documents.

pulse.subscribe()

Subscription options

The handler can return void or Promise<void>:
PulseReceivedEvent contains every published event field plus consumerGroup and the one-based attempt number. The returned subscription contains the resolved options and an idempotent asynchronous unsubscribe() method.

pulse.getSubscriptions()

Returns the subscriptions registered in this process. It does not query durable subscriptions created by other replicas. Use the dashboard to inspect the full database state.

pulse.history.find()

History filters

Results are sorted by UUIDv7 _id descending:
Each record exposes delivery and event IDs, topic, group, attempt number, status, lock state and timestamps, duration, expiration, and serialized error.

pulse.close()

Stops coordinator and worker execution, wakes sleepers, waits for background work to settle, and closes the MongoDB client. Repeated calls return the same close promise. When called and awaited from inside a handler, shutdown starts but that call returns before the shared promise so the current worker cannot deadlock waiting for itself. A call from outside the handler can await complete shutdown.

Exported errors

Collections

The names use collectionPrefix, which defaults to orionjs.pulse: Every Pulse-created _id, lock owner, and fencing token is a UUIDv7 string.

Automatically managed indexes

Pulse creates missing indexes and validates named indexes on every connection. It never drops an index automatically.

Events

Subscriptions

Deliveries

History

Full typed example