Skip to main content
The write option lets you fan events out to a non-Boundary destination — or replace the Boundary transport entirely. write is called with the full batch every time the batcher flushes.

Signature

Return a promise if your sink is async (most are). The batcher awaits it before the next flush runs.

Mirror mode — apiKey + write

Both fire on every flush. Useful for a local mirror during rollout:
The custom sink is not wrapped in the circuit breaker — it’s your code, you own its failure semantics. The HTTP transport to Boundary is always breaker-wrapped.

Replacement mode — write only

Omit apiKey and no HTTP traffic is sent. Every event goes only to your sink.
Note the dev-safe fallback: without apiKey and without write, createBoundaryLogger returns null. With either one configured, it returns a live logger.

Integrations

Pino

OpenTelemetry logs

Write to a file (Node only)

Kafka / SQS / your existing bus

Failure handling

If write throws or rejects, the batcher routes the error through onError:
The batch is considered “done” regardless — custom sinks do not retry automatically. If you need retry / durability, wrap your sink:

Back-pressure

write runs inline with the flush, so a slow sink slows flushes — which in turn makes the queue fill up faster. If your sink can block for long, either:
  • Apply maxQueueSize aggressively (lower it to something you’re comfortable dropping), or
  • Let write return quickly and buffer on its own (e.g. push to a local ring buffer that a worker drains).

See also

Batching

Flush triggers and queue overflow

Resilience

HTTP retry, circuit breaker, rate limits