@pidgeon-ai/sdk 1.66.1 → 1.67.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1835,17 +1835,23 @@ async function* streamEvents(options) {
1835
1835
  continue;
1836
1836
  }
1837
1837
  backoffMs = 1e3;
1838
- for await (const frame of frames(response.body, options.signal)) {
1839
- if (frame.id) lastEventId = frame.id;
1840
- if (!frame.data) continue;
1841
- if (frame.event === "error") continue;
1842
- let parsed;
1843
- try {
1844
- parsed = JSON.parse(frame.data);
1845
- } catch {
1846
- continue;
1838
+ try {
1839
+ for await (const frame of frames(response.body, options.signal)) {
1840
+ if (frame.id) lastEventId = frame.id;
1841
+ if (!frame.data) continue;
1842
+ if (frame.event === "error") continue;
1843
+ let parsed;
1844
+ try {
1845
+ parsed = JSON.parse(frame.data);
1846
+ } catch {
1847
+ continue;
1848
+ }
1849
+ yield parsed;
1847
1850
  }
1848
- yield parsed;
1851
+ } catch {
1852
+ if (options.signal?.aborted) return;
1853
+ await sleep(backoffMs, options.signal);
1854
+ backoffMs = Math.min(backoffMs * 2, 3e4);
1849
1855
  }
1850
1856
  }
1851
1857
  }