Commit 9510886
committed
refactor(status-fetcher): replace fetch-utils with Effect-based fetchers
Replaces the hand-rolled timeout+retry loop in packages/status-fetcher/src/fetch-utils.ts
with Effect's Schedule.exponential+jittered and Effect.timeoutFail. Each fetcher's fetch()
now returns Effect.Effect<StatusResult, FetchError> instead of Promise<StatusResult>, so the
downstream consumer in apps/workflows can compose typed errors directly via Effect.forEach +
Effect.either instead of Promise.allSettled.
Adds 'effect': '3.19.12' to packages/status-fetcher dependencies (matching apps/workflows).
Behavior changes (must be reviewed):
- Timeouts now retry up to 3 times like other transient errors. Worst-case per-entry time
grows from ~30s to ~120s. The outer Effect.retry({ times: 3 }) in external-status.ts is
removed to compensate (inner fetchJson retry is sufficient).
- Jitter formula differs slightly: today's +/-25% on planned delay -> Effect's
Schedule.jittered (uniform [delay, 2*delay]). Functionally equivalent for herd avoidance.
- FetchError constructor changed from positional args to options object:
new FetchError({ url, fetcherName?, entryId?, httpStatus?, cause? }). Added httpStatus
field so retry predicate skips 4xx without regex-matching the message.
- Public surface narrowed: fetchWithTimeout / fetchWithRetry / fetchWithDeduplication and
their option types removed from src/index.ts. No external consumers found.
- StatusFetcher.fetch signature: Promise<StatusResult> -> Effect.Effect<StatusResult, FetchError>.
Internal helpers fetchJson and fetchText are package-internal; only FetchError, fetcher
registry, and type surface are re-exported.
Also fixes pre-existing tsconfig typo (bun-types -> bun) and removes stale
@openstatus/status-fetcher dep from apps/web/package.json (no source imports).
Tests: 168 pass / 0 fail. README rewritten.1 parent 6282b27 commit 9510886
30 files changed
Lines changed: 1453 additions & 1979 deletions
File tree
- apps
- web
- workflows/src/cron
- packages/status-fetcher
- __tests__
- fetchers
- scripts
- src
- fetchers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | 39 | | |
41 | 40 | | |
42 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
77 | 91 | | |
78 | 92 | | |
79 | 93 | | |
80 | 94 | | |
81 | | - | |
82 | | - | |
83 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
84 | 98 | | |
85 | 99 | | |
86 | 100 | | |
87 | 101 | | |
88 | 102 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
| 103 | + | |
94 | 104 | | |
95 | 105 | | |
96 | 106 | | |
| |||
121 | 131 | | |
122 | 132 | | |
123 | 133 | | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | 134 | | |
129 | 135 | | |
130 | 136 | | |
| |||
0 commit comments