You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 24766a9
Browse filesBrowse the repository at this point in the historyBrowse files
This follows #2427 (`propagationEnabled` → `propagation`) and #2430,
which gave the event stream options and the batch plugin's `keepAlive`
the same shape. The options below wrapped a feature in `{ enabled:
boolean, ... }`. They now take `true`/`false` or an object, and passing
an object turns the feature on. You no longer need `enabled: true` just
to change a setting such as `ttl`, and more settings can be added later
without renaming anything.
## Changes
All of these are **breaking**:
| Before | After | Default |
|---|---|---|
| Publisher `resume: { enabled, ttl }` (memory, Redis, Upstash, Bun
Redis) | `resume?: boolean \| { ttl? }` | `false` |
| `DurablePublisherObject` `resume: { enabled, ... }` | `resume?:
boolean \| { ttl?, cleanupInterval?, schemaPrefix? }` | `false` |
| WebSocket link `reconnect: { enabled, ... }` | `reconnect?: boolean \|
{ delay?, maxAttempt?, maxTotalAttempt?, onClose? }` | `false` |
| `reconnect.onClose: { enabled, delay }` | `onClose?: boolean \| {
delay? }` | `false` |
```ts
new MemoryPublisher({ resume: true })
new MemoryPublisher({ resume: { ttl: 60_000 } })
new RPCLink({ connect, reconnect: { maxAttempt: 5, onClose: true } })
```
- `onClose` still applies only when `reconnect` is enabled.
- New exported type: `WebSocketLinkTransportReconnectOnCloseOptions`.
- Updated docs (publisher, WebSocket, v1 migration guide) and
playgrounds.
## Not changed
`disableInputValidation` and `disableOutputValidation` stay as they are.
## Tests
- `pnpm format`, `pnpm check` and `pnpm docs:validate` are clean.
- `pnpm test` passes, including Bun's runner.
- The Redis, Upstash and Bun Redis publisher suites need live services,
so they were skipped locally. The only change in `base-redis.ts` is how
the option is parsed.
- New cases cover `resume: false`, `reconnect: false`, `onClose: true`
and `onClose: { delay }`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01VVaw7SrpoYso5gPSupyRpk
---------
Co-authored-by: Claude <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: apps/content/docs/adapters/websocket.mdx
+15-17Lines changed: 15 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -267,18 +267,17 @@ The examples above only show how to configure the link. For examples of creating
267
267
268
268
### Auto Reconnect
269
269
270
-
The client adapter has built-in support for reconnecting when the connection is lost. You can configure reconnect behavior with the `reconnect` option when creating the link.
270
+
The client adapter has built-in support for reconnecting when the connection is lost. Enable it with `reconnect: true`when creating the link, or pass an object to customize it.
271
271
272
272
```ts
273
273
const link =newRPCLink({
274
+
/**
275
+
* Whether to automatically reconnect when the connection is lost.
276
+
* `true` enables it, an object enables and customizes it.
277
+
*
278
+
* @defaultfalse
279
+
*/
274
280
reconnect: {
275
-
/**
276
-
* Whether to automatically reconnect when the connection is lost.
277
-
*
278
-
* @defaultfalse
279
-
*/
280
-
enabled: true,
281
-
282
281
/**
283
282
* Delay before a (re)connect attempt, in milliseconds.
284
283
*
@@ -305,16 +304,15 @@ const link = new RPCLink({
305
304
*/
306
305
maxTotalAttempt: Infinity,
307
306
307
+
/**
308
+
* Whether to proactively reconnect right after the socket closes,
309
+
* rather than waiting for the next call to trigger reconnection.
310
+
* Reduces latency for the next request.
311
+
* `true` enables it, an object enables and customizes it.
312
+
*
313
+
* @defaultfalse
314
+
*/
308
315
onClose: {
309
-
/**
310
-
* Whether to proactively reconnect right after the socket closes,
311
-
* rather than waiting for the next call to trigger reconnection.
312
-
* Reduces latency for the next request.
313
-
*
314
-
* @defaultfalse
315
-
*/
316
-
enabled: false,
317
-
318
316
/**
319
317
* Delay before reconnecting after the socket closes, in milliseconds.
* Event resume support. `true` enables it, an object enables and customizes it.
264
+
*
265
+
* When enabled, published events are temporarily stored so new
266
+
* subscribers can resume from a previous position using `lastEventId`.
267
+
* Each stored event must fit within the Durable Object SQLite row size limit,
268
+
* so publishing a larger one fails.
269
+
*
270
+
* @defaultfalse
271
+
*/
270
272
resume: {
271
-
/**
272
-
* Whether event resume support is enabled.
273
-
*
274
-
* When enabled, published events are temporarily stored so new
275
-
* subscribers can resume from a previous position using `lastEventId`.
276
-
* Each stored event must fit within the Durable Object SQLite row size limit,
277
-
* so publishing a larger one fails.
278
-
*
279
-
* @defaultfalse
280
-
*/
281
-
enabled: false,
282
-
283
273
/**
284
274
* How long to retain events for resume, in milliseconds.
285
275
*
@@ -348,12 +338,15 @@ export default {
348
338
349
339
## Resume Missing Events
350
340
351
-
Some adapters can resume events missed while a subscriber is offline. This feature is usually disabled by default, but you can enable it when creating the publisher. When enabled, the publisher automatically manages event ids and attempts to deliver events since the last event id provided by the subscriber.
341
+
Some adapters can resume events missed while a subscriber is offline. This feature is usually disabled by default, but you can enable it when creating the publisher with `resume: true`, or with an object to customize it. When enabled, the publisher automatically manages event ids and attempts to deliver events since the last event id provided by the subscriber.
352
342
353
343
```ts
354
344
const publisher =newMemoryPublisher({
345
+
resume: true, // Enable resuming missed events
346
+
})
347
+
348
+
const customized =newMemoryPublisher({
355
349
resume: {
356
-
enabled: true, // Enable resuming missed events
357
350
ttl: 5*60*1000, // How long to retain events, in milliseconds
0 commit comments