feat(/w3c/update): add endpoint to trigger groups data refresh#505
Conversation
There was a problem hiding this comment.
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.jsonat 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.
There was a problem hiding this comment.
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.
c24e531 to
f370d51
Compare
There was a problem hiding this comment.
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.
f370d51 to
fb4fd8b
Compare
There was a problem hiding this comment.
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.
fb4fd8b to
641e741
Compare
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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
641e741 to
14aa77f
Compare
There was a problem hiding this comment.
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.
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.
There was a problem hiding this comment.
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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
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.
|
@copilot can you fix those? |
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>
|
@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. |
Agent-Logs-Url: https://github.com/speced/respec-web-services/sessions/728917e2-18ac-49b2-8ef9-9630dfdc2e9f Co-authored-by: marcoscaceres <870154+marcoscaceres@users.noreply.github.com>
All feedback has been addressed in 33c5e5f:
|
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
|
|
||
| const w3c = Router(); | ||
| w3c.get("/groups{/:shortname}{/:type}", cors(), groupsRoute); | ||
| w3c.post("/update", updateRoute); |
There was a problem hiding this comment.
Should we add the cron call from a GitHub action? Or something on the server (using cron or pm2)
There was a problem hiding this comment.
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.
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>
sidvishnoi
left a comment
There was a problem hiding this comment.
LGTM code-wise, but what'll trigger the GitHub webhook??
|
|
||
| const w3c = Router(); | ||
| w3c.get("/groups{/:shortname}{/:type}", cors(), groupsRoute); | ||
| w3c.post("/update", authGithubWebhook(env("W3C_GROUPS_SECRET")), updateRoute); |
There was a problem hiding this comment.
What will trigger this webhook?
There was a problem hiding this comment.
it's supposed to be a cron job.
There was a problem hiding this comment.
Similar to this:
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Yeah, does that sound ok?
Summary
Replaces the closed PR #496 (which incorrectly tried to use GitHub Actions).
setIntervalthat calls the W3C groups update script every 24 hours on the running servergroups.jsongracefully at startup (empty store instead of crash)setIntervalpattern from xref cache invalidationCloses #395