Skip to content

fix: adobe provider - refresh kit meta when font is not resolved #198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

drevantonder
Copy link

Fixes #197

Updates the Adobe provider:

  • Updates the kit fetching to allow for bypassing the cache
  • Re-fetches the kit if a font is missing

Update tests:

  • Adds a test for the above
  • Updates the handles invalid JSON from adobe api Might need to be in a separate PR?
    • Restores console.error by calling vi.restoreAllMocks() (Errors whilst I wrote the tests weren't working)
    • Update the mock fetch to return a promise (or TypeError: fetch(...).then is not a function is actually thrown, not the error that is expected)

@drevantonder drevantonder requested a review from danielroe as a code owner June 2, 2025 12:13
@danielroe
Copy link
Member

this will end up refetching adobe kits on every request for a font family that the kit doesn't have. this gets called a lot, so this doesn't seem to be the right approach.

some ideas to consider (possibly implementing all of them):

  • allow adobe to accept an option to automatically 'refresh'
  • a timeout/debounce based approach that doesn't refresh any more frequently than x seconds
  • cache font families that are not included in the kit even after a refresh so we don't keep refreshing it for them

@drevantonder
Copy link
Author

drevantonder commented Jun 3, 2025

oh, haha, that would be pretty undesirable to have a refetch every request 😅.

As an alternative to the spammy requests, how does this sound?

  • Fetch and cache all the available font families by using api/v1/json/libraries/full (with a little pagination)
  • In resolveFont, if a font is requested (and at least one kit id is provided so we don't spam non-adobe users) that is not in the kit but is available in Adobe, print a warning like ${fontFamily} is available from Adobe but not in the provided kits. Restart if you've changed a kit or add the font family to a kit and restart.
  • When the above occurs, add a flag item (e.g. refetch-adobe-kits.json) to the cache to reload the kit on the next restart if this item exists.

This would:

  • Avoid making spammy requests
  • Warn the developer if needed and provide instructions to fix

If that sounds sub-optimal, I'm happy to implement the debouncing. I'll implement the above to have a proof of concept.

@drevantonder
Copy link
Author

drevantonder commented Jun 3, 2025

api/v1/json/libraries/full takes a while with pagination (~20sec). I'll attempt the debouncing method.

@drevantonder
Copy link
Author

I've implemented a simple debounce mechanism and a negative cache. I've set it currently to 5 minutes between refreshes.

As to a refresh option. I guess I'm biased to not have it as this figuring out that the kits were being cached, where they were being cached, and how long was a pain, but I'm happy to add a refresh option If you think better? (If so, would we want it to default to true or false?)

@drevantonder drevantonder changed the title fix: adobe provider - refetch kit meta when font is not in cache fix: adobe provider - refresh kit meta when font is not resolved Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adobe provider cache doesn't fetch kit changes for a week
2 participants