Skip to content

feat(/w3c/update): add endpoint to trigger groups data refresh#505

Merged
marcoscaceres merged 22 commits into
mainfrom
feat/auto-refresh-groups
May 19, 2026
Merged

feat(/w3c/update): add endpoint to trigger groups data refresh#505
marcoscaceres merged 22 commits into
mainfrom
feat/auto-refresh-groups

Conversation

@marcoscaceres

Copy link
Copy Markdown
Collaborator

Summary

Replaces the closed PR #496 (which incorrectly tried to use GitHub Actions).

  • Adds setInterval that calls the W3C groups update script every 24 hours on the running server
  • Reloads in-memory groups data from disk after each update
  • Handles missing groups.json gracefully at startup (empty store instead of crash)
  • Follows existing setInterval pattern from xref cache invalidation

Closes #395

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Implements server-side auto-refresh of the W3C groups list so /w3c/groups stays up-to-date without relying on external automation.

Changes:

  • Schedule a 24-hour refresh that runs the W3C groups update script and reloads in-memory data from disk.
  • Make the W3C groups route resilient to a missing groups.json at startup (empty store fallback).
  • Improve sh() by rejecting on child process errors and waiting for "close" instead of "exit".

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
utils/sh.ts Improves child process lifecycle handling by listening for "error" and "close".
routes/w3c/group.ts Adds periodic refresh + in-memory reload logic; adds startup fallback when groups.json is absent.
docs/superpowers/plans/2026-04-25-typescript6-migration.md Adds internal planning doc (not directly related to W3C groups refresh).
docs/superpowers/plans/2026-04-25-test-coverage-blitz.md Adds internal planning doc (not directly related to W3C groups refresh).
docs/superpowers/plans/2026-04-25-node24-modernization.md Adds internal planning doc (not directly related to W3C groups refresh).
.claude/scheduled_tasks.lock Adds a Claude runtime lockfile artifact.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread routes/w3c/group.ts Outdated
Comment thread routes/w3c/group.ts Outdated
Comment thread routes/w3c/group.ts Outdated
Comment thread routes/w3c/group.ts Outdated
Comment thread docs/superpowers/plans/2026-04-25-typescript6-migration.md Outdated
Comment thread docs/superpowers/plans/2026-04-25-test-coverage-blitz.md Outdated
Comment thread docs/superpowers/plans/2026-04-25-node24-modernization.md Outdated
Comment thread .claude/scheduled_tasks.lock Outdated
@marcoscaceres marcoscaceres requested a review from Copilot April 26, 2026 01:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/superpowers/plans/2026-04-25-test-coverage-blitz.md Outdated
Comment thread docs/superpowers/plans/2026-04-25-node24-modernization.md Outdated
Comment thread routes/w3c/group.ts Outdated
Comment thread docs/superpowers/plans/2026-04-25-typescript6-migration.md Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread routes/w3c/group.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread routes/w3c/group.ts Outdated
Comment thread routes/w3c/group.ts Outdated
Comment thread routes/w3c/group.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread routes/w3c/group.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread routes/w3c/group.ts Outdated
Adds a setInterval that calls the update script daily and reloads
the in-memory groups data from disk. Follows the existing pattern
from xref's periodic cache invalidation.

Also handles missing groups.json gracefully at startup (empty store
instead of crash).

Closes #395

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread routes/w3c/group.ts Outdated
Replace setInterval with self-scheduling setTimeout so the next
refresh only fires after the current one completes. Add in-flight
guard for safety. On startup JSON parse failure, trigger an
immediate refreshGroups() to self-heal.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread routes/w3c/group.ts Outdated
Comment thread routes/w3c/group.ts Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread routes/w3c/group.ts Outdated
Comment thread routes/w3c/group.ts Outdated
Comment thread routes/w3c/group.ts Outdated
@marcoscaceres

Copy link
Copy Markdown
Collaborator Author

@copilot can you fix those?

marcoscaceres and others added 5 commits April 27, 2026 19:26
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@marcoscaceres

Copy link
Copy Markdown
Collaborator Author

@copilot can you confirm all your feedback has been addressed and resolved everything that has? Can you fix anything that wasn’t addressed and resolve those comments.

Copilot AI commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

@copilot can you confirm all your feedback has been addressed and resolved everything that has? Can you fix anything that wasn’t addressed and resolve those comments.

All feedback has been addressed in 33c5e5f:

  • Corrupted file: Restored from the clean 06a077c baseline (previous "Apply suggestion" commits had merged code without removing old code)
  • reloadGroups() boolean return: Now returns true/false so refreshGroups() only logs success when the reload actually worked
  • Retry on any failure: nextDelay now uses refreshed ? 24h : 15m — retries sooner on any failure, not just missing-file cases
  • All other previously-resolved items (lazy import, in-flight guard, EMPTY_GROUPS fallback, self-scheduling setTimeout, immediate refresh on missing/corrupt file) remain in place

@marcoscaceres marcoscaceres marked this pull request as ready for review April 27, 2026 19:58
Comment thread routes/w3c/group.ts Outdated
Comment thread routes/w3c/group.ts Outdated
Comment thread routes/w3c/group.ts Outdated
Restructured per review feedback:
- Use BackgroundTaskQueue with worker thread (matches xref/caniuse)
- Only write groups.json on successful scrape
- Add POST /w3c/update endpoint for cron-triggered refreshes
- Remove inline setTimeout/setInterval timer
Comment thread routes/w3c/group.ts Outdated
Comment thread routes/w3c/group.ts Outdated
Comment thread routes/w3c/index.ts Outdated

const w3c = Router();
w3c.get("/groups{/:shortname}{/:type}", cors(), groupsRoute);
w3c.post("/update", updateRoute);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we add the cron call from a GitHub action? Or something on the server (using cron or pm2)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'd lean toward a GitHub Action with schedule: cron trigger that hits POST /w3c/update, matching how we could trigger xref/caniuse externally. Keeps the cron config in version control and avoids pm2/server config. Happy to set that up as a follow-up PR once this lands.

Comment thread routes/w3c/index.ts Outdated
marcoscaceres and others added 3 commits May 3, 2026 18:13
Remove redundant existsSync guards (readFileSync throws into catch).
Add authGithubWebhook middleware to POST /w3c/update to prevent spam.
Add W3C_GROUPS_SECRET to .env.sample.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The reloadGroups() return value was silently discarded, so a
successful scrape followed by a failed reload would return 200.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@marcoscaceres marcoscaceres requested a review from sidvishnoi May 15, 2026 03:02

@sidvishnoi sidvishnoi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM code-wise, but what'll trigger the GitHub webhook??

Comment thread routes/w3c/index.ts

const w3c = Router();
w3c.get("/groups{/:shortname}{/:type}", cors(), groupsRoute);
w3c.post("/update", authGithubWebhook(env("W3C_GROUPS_SECRET")), updateRoute);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What will trigger this webhook?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

it's supposed to be a cron job.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@sidvishnoi sidvishnoi May 15, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A cron GitHub action in this repo, that sends a request to update endpoint? Will it have same payload format we expect in authGithubWebhook?

Edit: just saw #505 (comment)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, does that sound ok?

@sidvishnoi sidvishnoi changed the title feat(w3c): auto-refresh groups list every 24 hours feat(/w3c/update): add endpoint to trigger groups data refresh May 15, 2026
@marcoscaceres marcoscaceres merged commit dec4ca3 into main May 19, 2026
3 checks passed
@marcoscaceres marcoscaceres deleted the feat/auto-refresh-groups branch May 19, 2026 02:09
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.

w3c/groups: auto-update list of working groups

4 participants