@@ -7,10 +7,6 @@ export const MIN_DELAY = 100; // 100 ms
77export const START_DELAY = 5_000 ; // 5 seconds
88const MAX_DELAY = 3.6e6 ; // 1 hour
99
10- function log ( msg : string , error ?: Error ) : void {
11- DEBUG_BUILD && logger . info ( `[Offline]: ${ msg } ` , error ) ;
12- }
13-
1410export interface OfflineStore {
1511 push ( env : Envelope ) : Promise < void > ;
1612 unshift ( env : Envelope ) : Promise < void > ;
@@ -54,6 +50,10 @@ type Timer = number | { unref?: () => void };
5450export function makeOfflineTransport < TO > (
5551 createTransport : ( options : TO ) => Transport ,
5652) : ( options : TO & OfflineTransportOptions ) => Transport {
53+ function log ( ...args : unknown [ ] ) : void {
54+ DEBUG_BUILD && logger . info ( '[Offline]:' , ...args ) ;
55+ }
56+
5757 return options => {
5858 const transport = createTransport ( options ) ;
5959
@@ -130,6 +130,8 @@ export function makeOfflineTransport<TO>(
130130 // If there's a retry-after header, use that as the next delay.
131131 if ( result . headers && result . headers [ 'retry-after' ] ) {
132132 delay = parseRetryAfterHeader ( result . headers [ 'retry-after' ] ) ;
133+ } else if ( result . headers && result . headers [ 'x-sentry-rate-limits' ] ) {
134+ delay = 60_000 ; // 60 seconds
133135 } // If we have a server error, return now so we don't flush the queue.
134136 else if ( ( result . statusCode || 0 ) >= 400 ) {
135137 return result ;
@@ -148,7 +150,7 @@ export function makeOfflineTransport<TO>(
148150 await store . push ( envelope ) ;
149151 }
150152 flushWithBackOff ( ) ;
151- log ( 'Error sending. Event queued' , e as Error ) ;
153+ log ( 'Error sending. Event queued. ' , e as Error ) ;
152154 return { } ;
153155 } else {
154156 throw e ;
0 commit comments