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
Registers a persistent handler that fires on every piece of data. Returns a subscription with an `.off()`method.
239
+
Registers a persistent handler that fires on every piece of data. Handlers are automatically cleaned up when the task run completes, so you don't need to manually unsubscribe. If you need to stop listening early (before the run ends), call `.off()`on the returned subscription.
1.**Use `.wait()` for long waits**: If the task has nothing else to do until data arrives (approval gates, human-in-the-loop), use `.wait()` to free compute resources. Use `.once()` only for short waits or when doing concurrent work.
412
-
2.**Always clean up listeners**: Call `.off()`in a `finally` block when using `.on()` to prevent memory leaks
400
+
2.**Listeners auto-cleanup**: `.on()`handlers are automatically cleaned up when the task run completes. Call `.off()`only if you need to stop listening early
413
401
3.**Use timeouts**: Both `.wait()` and `.once()` support timeouts — always set one to avoid indefinite hangs
414
402
4.**Use idempotency keys with `.wait()`**: If your task has retries enabled, pass an `idempotencyKey` to `.wait()` so retries resume the same wait instead of creating a new one
415
403
5.**Define streams in shared files**: Keep your `streams.input()` definitions in a shared location (like `trigger/streams.ts`) so both task code and backend/frontend can import them with full type safety
0 commit comments