Skip to content

withWatchdog

function withWatchdog(provider, opts?): Provider;

Defined in: core/src/watchdog.ts:301

A provider with both silent failures already handled.

Every consumer of this package wrote the same three lines around every createStream: build a watch, hand the provider the watch’s signal, wrap the chunks. The middle one is the trap. Pass the caller’s signal instead and everything still compiles, still streams, still passes the tests: the watchdog simply never aborts anything, because the request it was meant to cancel was never told about it. The failure has no symptom until production, where it is the exact hang the watchdog was added to end.

So the composition belongs here rather than in a docs snippet each app copies. The result is still a Provider, so it composes unchanged with withStreamRetry and streamWithBackupModels. Timeouts and empty turns without a length finish are transient, so wrapping it in a retry is safe. The one timeout a replay would make worse, no response at all within the progress window, says so itself with shouldRetry: false.

Parameter Type
provider Provider
opts WatchdogOptions

Provider