Skip to content

Commit

Permalink
client: fix inferred refresh interval
Browse files Browse the repository at this point in the history
  • Loading branch information
pbohlman committed Nov 23, 2024
1 parent 51895b7 commit 483c84b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/empty-berries-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@triplit/client': patch
---

fix refresh interval
5 changes: 5 additions & 0 deletions .changeset/manual-cli-changeset.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@triplit/cli': patch
---

Manual version bump for CLI dependencies
2 changes: 1 addition & 1 deletion packages/client/src/client/triplit-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ export class TriplitClient<M extends ClientSchema = ClientSchema> {
const setRefreshTimeoutForToken = (refreshToken: string) => {
const decoded = decodeToken(refreshToken);
if (!decoded.exp && !interval) return;
let delay = interval ?? decoded.exp - Date.now() - 1000;
let delay = interval ?? decoded.exp * 1000 - Date.now() - 1000;
if (delay < 1000) {
this.logger.warn(
`The minimum allowed refresh interval is 1000ms, the ${interval ? 'provided interval' : 'interval determined from the provided token'} was ${Math.round(delay)}ms.`
Expand Down

0 comments on commit 483c84b

Please sign in to comment.