(key: string)
| 12 | const DEDUP_WINDOW_MS = 10_000 |
| 13 | |
| 14 | function shouldReport(key: string): boolean { |
| 15 | const now = Date.now() |
| 16 | const last = recent.get(key) |
| 17 | if (last !== undefined && now - last < DEDUP_WINDOW_MS) return false |
| 18 | recent.set(key, now) |
| 19 | // Bound the map so it can't grow without limit. |
| 20 | if (recent.size > 100) { |
| 21 | for (const [k, t] of recent) { |
| 22 | if (now - t >= DEDUP_WINDOW_MS) recent.delete(k) |
| 23 | } |
| 24 | } |
| 25 | return true |
| 26 | } |
| 27 | |
| 28 | export function reportError(message: string, stack?: string): void { |
| 29 | if (!message) return |
no test coverage detected