@@ -38,7 +38,9 @@ export async function createEdgeConfigDataAdapter(options: {
38
38
* Statsig syncs config specs outside of the request context,
39
39
* so we will support it in triggering config spec synchronization in this case.
40
40
*/
41
- export const createSyncingHandler = ( ) : null | ( ( ) => void ) => {
41
+ export const createSyncingHandler = (
42
+ minSyncDelayMs : number ,
43
+ ) : null | ( ( ) => void ) => {
42
44
// Syncing both in Edge Runtime and Node.js for now, as the sync is otherwise
43
45
// not working during local development.
44
46
//
@@ -50,17 +52,15 @@ export const createSyncingHandler = (): null | (() => void) => {
50
52
// - the broken syncing due to issues in Date.now in Edge Runtime would be irrelevant
51
53
//
52
54
// if (typeof EdgeRuntime === 'undefined') return null;
53
-
54
- const timerInterval = 5_000 ;
55
55
let isSyncingConfigSpecs = false ;
56
- let nextConfigSpecSyncTime = Date . now ( ) + timerInterval ;
56
+ let nextConfigSpecSyncTime = Date . now ( ) + minSyncDelayMs ;
57
57
return ( ) : void => {
58
58
if ( Date . now ( ) >= nextConfigSpecSyncTime && ! isSyncingConfigSpecs ) {
59
59
try {
60
60
isSyncingConfigSpecs = true ;
61
61
const sync = Statsig . syncConfigSpecs ( ) . finally ( ( ) => {
62
62
isSyncingConfigSpecs = false ;
63
- nextConfigSpecSyncTime = Date . now ( ) + timerInterval ;
63
+ nextConfigSpecSyncTime = Date . now ( ) + minSyncDelayMs ;
64
64
} ) ;
65
65
import ( '@vercel/functions' ) . then ( ( { waitUntil } ) => {
66
66
waitUntil ( sync ) ;
0 commit comments