LCOV - code coverage report
Current view: top level - src/platform/billing - refreshBalanceInBackground.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 50.0 % 8 4
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import { reportError } from '@comfyorg/telemetry/reportError'
       2              : 
       3         2355 : const REPORT_INTERVAL_MS = 5 * 60_000
       4         2355 : let lastReportedAt = Number.NEGATIVE_INFINITY
       5              : 
       6              : /** Reads the balance for a caller that does not await it; reports a failure at most every 5 minutes and never rejects. */
       7            7 : export function refreshBalanceInBackground(
       8              :   fetchBalance: () => Promise<unknown>
       9              : ): Promise<void> {
      10            7 :   return fetchBalance().then(
      11              :     () => undefined,
      12              :     (error: unknown) => {
      13            0 :       const now = Date.now()
      14            0 :       if (now - lastReportedAt < REPORT_INTERVAL_MS) return
      15            0 :       lastReportedAt = now
      16            0 :       reportError(error, {
      17              :         surface: 'billing',
      18              :         errorType: 'error_refreshing_balance',
      19              :         level: 'warning'
      20              :       })
      21              :     }
      22              :   )
      23              : }
        

Generated by: LCOV version 2.0-1