Skip to content

Commit 196c9ea

Browse files
committed
Handling 0 < X < 30 expiration time check.
1 parent ed480cd commit 196c9ea

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

packages/common/src/client/sync/stream/AbstractRemote.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ export type RemoteConnector = {
2121
const POWERSYNC_TRAILING_SLASH_MATCH = /\/+$/;
2222
const POWERSYNC_JS_VERSION = PACKAGE.version;
2323

24-
// Refresh at least 30 sec before it expires
25-
const REFRESH_CREDENTIALS_SAFETY_PERIOD_MS = 30_000;
2624
const SYNC_QUEUE_REQUEST_LOW_WATER = 5;
2725

2826
// Keep alive message is sent every period

packages/common/src/client/sync/stream/AbstractStreamingSyncImplementation.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,11 @@ The next upload iteration will be delayed.`);
691691
*/
692692
await this.delayRetry();
693693
return;
694+
} else if (remaining_seconds < 30) {
695+
this.logger.debug('Token will expire soon; reconnect');
696+
// Pre-emptively refresh the token
697+
this.options.remote.invalidateCredentials();
698+
return;
694699
}
695700
this.triggerCrudUpload();
696701
} else {

0 commit comments

Comments
 (0)