Repository navigation
refactor(db): one refreshing-value helper for cloud credential caches - #2302
Merged
Merged
Conversation
Move the Google token source's cache, 60-second early refresh, shared refresh on its own 30-second deadline, caller abort handling and close() into src/lib/db/auth/refresh.ts as createRefreshingValue, so the next cloud credential that expires reuses it instead of a second copy. Behaviour is unchanged; the Google token-source tests pass as they were.
Review round 1: pin one deadline per shared refresh, name the close() test after what it proves, and rewrap the token source docblock.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
17 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Moves the Google token source's cache and refresh logic into
src/lib/db/auth/refresh.tsascreateRefreshingValue, so the next cloud credential that expires (such as a temporary database password) reuses one implementation instead of copying it.Behaviour is unchanged:
tests/unit/db/auth/google/token-source.test.tspasses without a single edit.What changes
src/lib/db/auth/refresh.tsis new and holds what the token source kept inline: the cached value served untilexpiresAt - earlyMs, one shared refresh on its own 30-second deadline combined withclose(), a caller's own abort that rejects only that caller (with the same twoTransportErrorsentences), nothing cached from a failed refresh, andclose().RefreshRun(the refresh'ssignalandthrowIfClosed()) and the privateuntilAbortedmove with it unchanged.throwIfClosed()still readsclose()alone, so a deadline that fires while a key is signed is reported as a timeout, never as closed.src/lib/db/auth/google/token-source.tskeeps its strategies, lanes and token-answer parsing and hands the cache tocreateRefreshingValuewith its 60-second margin and its closed sentence;close()still closes every lane it built.tests/unit/db/auth/refresh.test.tscovers the helper on its own: single flight with one deadline, the early-refresh boundary at exactlyexpiresAt - earlyMs, the deadline, one caller's abort leaving the others, a failure caching nothing,close()during a refresh,get()afterclose(), and a deadline during a step that takes no signal.tests/unit/db/auth/seam-guard.test.tslists the new layer file.docs/DB_AUTH.mdgains a Root pieces row and a "Shared refresh" section; theauth/line ofdocs/ARCHITECTURE.mdnamesrefresh.ts.User-visible change
None.
Test plan