Skip to content

Commit

Permalink
cleanup cookie state on expiration
Browse files Browse the repository at this point in the history
  • Loading branch information
nl0 committed Apr 25, 2024
1 parent 0ee8f8e commit 831c446
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions catalog/app/utils/PFSCookieManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,11 @@ export function PFSCookieManager({ children }: React.PropsWithChildren<{}>) {
if (state.token === token) return

const ttlLeft = Math.ceil((state.expires.getTime() - Date.now()) / 1000)
// bail if cookie has expired (noone's using it)
if (ttlLeft <= 0) return
if (ttlLeft <= 0) {
// cookie expired (noone's using it) -- cleanup state and bail
stateRef.current = undefined
return
}

state.token = token
state.promise = setPFSCookie(token, ttlLeft)
Expand Down

0 comments on commit 831c446

Please sign in to comment.