Skip to content

Added delay before purging jsDelivr cache #23107

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

sagzy
Copy link
Contributor

@sagzy sagzy commented Apr 30, 2025

ref https://linear.app/ghost/issue/PROD-1573

  • last week, purging jsDelivr cache after publishing a new NPM version of admin-x-activitypub was unreliable:

    • we released a new version (0.6.68) of our JS package, admin-x-activitypub, last Thursday 24/04 around ~17:45 UTC. The cache was purged immediately after and Mike could see the latest version on his production site 
    • but, on the next day, Mike opened his production site again and was served a previous version. Same browser / same location (no VPN)
  • release process:

    1. We bump the version of a package in a commit
    2. Once the commit is merged to our main branch, CI checks whether a new version has been created, and if yes, publishes a new version to npm
    3. Once a new version has been published, CI immediately clears jsDelivr cache
  • after reaching out to jsDelivr, the suggested fix was to add a 1-minute delay between publishing a new NPM version and purging jsDelivr cache

  • we're adding the 1-min delay in this commit and will monitor / open back the investigation if problem happens again

ref https://linear.app/ghost/issue/PROD-1573

- last week, purging jsDelivr cache after publishing a new NPM version of admin-x-activitypub was unreliable:
   - we released a new version (0.6.68) of our JS package, admin-x-activitypub, last Thursday 24/04 around ~17:45 UTC. The cache was purged immediately after and Mike could see the latest version on my production site 
   - but, on the next day, Mike opened my production site again and was served a previous version. Same browser / same location (no VPN)

- our release process:
    1. We bump the version of a package in a commit
    2.  Once the commit is merged to our main branch, our CI checks whether a new version has been created, and if yes, publishes a new version to npm (open-source code →)
    3. Once a new version has been published, CI immediately clears jsDelivr cache

- after reaching out to jsDelivr, the suggested fix was to add a 1-minute delay between publishing a new NPM version and purging jsDelivr cache
- we're adding the 1-min delay in this comment and will monitor / open back the investigation if problem happens again
Copy link
Contributor

coderabbitai bot commented Apr 30, 2025

Walkthrough

The GitHub Actions workflow configuration (.github/workflows/ci.yml) was modified to add a conditional waiting step before purging the jsDelivr cache. Specifically, if the package version has changed and the package is @tryghost/admin-x-activitypub, the workflow waits for 60 seconds before proceeding to purge the jsDelivr cache. The subsequent cache purge step remains and executes for any package with a changed version. No changes were made to exported or public entity declarations.

Suggested labels

deploy-to-staging


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 11e519b and 7d4873a.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/ci.yml
⏰ Context from checks skipped due to timeout of 90000ms (13)
  • GitHub Check: Signup-form tests
  • GitHub Check: Regression tests (Node 20.11.1, sqlite3)
  • GitHub Check: Database tests (Node 20.11.1, sqlite3)
  • GitHub Check: Regression tests (Node 20.11.1, mysql8)
  • GitHub Check: Database tests (Node 22.13.1, mysql8)
  • GitHub Check: Ghost-CLI tests
  • GitHub Check: Database tests (Node 20.11.1, mysql8)
  • GitHub Check: Comments-UI tests
  • GitHub Check: Admin-X Settings tests
  • GitHub Check: Unit tests (Node 22.13.1)
  • GitHub Check: Unit tests (Node 20.11.1)
  • GitHub Check: Lint
  • GitHub Check: Admin tests - Chrome

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
.github/workflows/ci.yml (1)

1333-1338: Consider using a dedicated wait action for clarity
The inline sleep 60 correctly implements the one-minute delay before purging the jsDelivr cache as recommended. To make the intent more explicit and maintainable, you could swap the shell block for a standard GitHub Action:

- name: Wait 60 seconds
  uses: actions/wait@v1
  with:
    time: 60

This avoids inline scripting and clearly signals the purpose of the step.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c0e740c and 11e519b.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (14)
  • GitHub Check: Signup-form tests
  • GitHub Check: Regression tests (Node 20.11.1, sqlite3)
  • GitHub Check: Ghost-CLI tests
  • GitHub Check: Regression tests (Node 20.11.1, mysql8)
  • GitHub Check: Comments-UI tests
  • GitHub Check: Database tests (Node 20.11.1, sqlite3)
  • GitHub Check: Admin-X Settings tests
  • GitHub Check: Unit tests (Node 22.13.1)
  • GitHub Check: Database tests (Node 22.13.1, mysql8)
  • GitHub Check: Unit tests (Node 20.11.1)
  • GitHub Check: Database tests (Node 20.11.1, mysql8)
  • GitHub Check: Unit tests (Node 18.12.1)
  • GitHub Check: Database tests (Node 18.12.1, mysql8)
  • GitHub Check: Admin tests - Chrome

Copy link
Member

@ErisDS ErisDS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a minute to the build time really isn't ideal. Feels a bit off to do that to fix something that happened once in all the time we've used jsDelivr.

Would you mind explaining why we need to purge the jsDelivr cache?

@ErisDS
Copy link
Member

ErisDS commented Apr 30, 2025

From reading the issue, maybe it's happened more than once? Sorry if I missed that!

@sagzy
Copy link
Contributor Author

sagzy commented Apr 30, 2025

@ErisDS Two occurrences that we've noticed so far, but in general it's about being sure that a change we expect to be in production is really in production.

Use case for ActivityPub: we ship changes and communicate them in the weekly newsletter; by the time the newsletter is sent, we'd like to be sure the change is in production for all users.

Our process: ship a new version of the AP frontend, then purge jsDelivr cache to make sure all users are being served the latest version (in theory)

What's happening sometimes (2 times so far): we think that we've shipped a new version to all users, but jsDelivr is still serving an old version; making our release pipeline unreliable/unpredictable.

This change should not add one minute delay to all CI runs: the delay is only added to commits on main that contains a version bump for either ActivityPub frontend, Portal, Sodo Search or Comments. All other CI runs should be unaffected by the change.

Is that more acceptable?

@ErisDS
Copy link
Member

ErisDS commented Apr 30, 2025

Yeah I realise it's only added to CI runs that affect the apps, but it still feels like the wrong fix to me.

I apologise if I'm being dumb, but I don't understand why the jsDelivr cache needs purging at all - so I'm trying to see if there's a way to delete that requirement by fixing something else?

@ErisDS
Copy link
Member

ErisDS commented Apr 30, 2025

FWIW short term, I think you can add && matrix.package_name == '@tryghost/admin-x-activitypub' to the step that waits 1min, so that you can see if this actually fixes the issue you're seeing in activitypub?

Then we can take our time to figure out what the right solution is

@sagzy
Copy link
Contributor Author

sagzy commented May 1, 2025

@ErisDS We load admin-x-activitypub inside Ghost Admin by requesting https://cdn.jsdelivr.net/ghost/admin-x-activitypub@0/dist/admin-x-activitypub.js (note the @0 version range, not a specific pinned version).

When a new version of admin-x-activitypub is published on 0.x.x, we can expect it to be served to users instantly given that it's within the version range requested in the code. This strategy helps us ship changes in admin-x-activitypub to production without having to wait for a Ghost rollout.

Now by default, jsDelivr caches assets for up to 7 days. So unless we actively ask jsDelivr to purge their cache, they won't be serving the latest version instantly to all production users.

Copy link

codecov bot commented May 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.85%. Comparing base (f52efed) to head (7d4873a).
Report is 82 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #23107      +/-   ##
==========================================
- Coverage   71.86%   71.85%   -0.01%     
==========================================
  Files        1432     1435       +3     
  Lines       99403    99433      +30     
  Branches    12211    12219       +8     
==========================================
+ Hits        71435    71450      +15     
- Misses      26984    26994      +10     
- Partials      984      989       +5     
Flag Coverage Δ
admin-tests 48.57% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sagzy
Copy link
Contributor Author

sagzy commented May 1, 2025

@ErisDS I have restricted the wait step for the admin-x-activitypub package as suggested - do you feel good about moving forward with the test with that restriction in place?

@sagzy
Copy link
Contributor Author

sagzy commented May 5, 2025

@ErisDS I have restricted the wait step for the admin-x-activitypub package as suggested - do you feel good about moving forward with the test with that restriction in place?

@ErisDS Oups missed that you're off this week! Based on your previous message, I will assume you're in board with the test as long as it's bounded to admin-x-activitypub only — if I misread, lmk I will revert the change

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.

2 participants