Skip to main content

connect()

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

Connection options

Strings must be non-empty. Durations and worker counts must be finite positive numbers, except retention, retry counts, and retry delays may be zero where their types allow it.

pulse.awaitConnection()

Resolves after the MongoDB client connects, the database is selected, collections and indexes are ready, and Change Stream support is resolved. 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 worker loops, wakes sleepers, closes the Change Stream, waits for background loops to settle, and closes the MongoDB client. Repeated calls return the same close promise.

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