Cleaned up ActivityPub boot noise when sibling service is offline#28996
Cleaned up ActivityPub boot noise when sibling service is offline#289969larsons wants to merge 1 commit into
Conversation
no ref - getWebhookSecret() classified an expected dev-mode condition (sibling ActivityPub container not running) as ERROR with a confusing FetchError / SyntaxError stack trace, then logged a phantom follow-up ERROR from the !secret branch in initialiseWebhooks(); ~4 red lines per boot - now catches FetchError (network failure) and SyntaxError (HTML fallthrough from Caddy → Ghost frontend) and logs a single INFO with actionable wording; everything else rethrows so production failures still surface - the wrapper's configureActivityPub() previously relied on getWebhookSecret swallowing all errors; added a try/catch so rethrown errors are logged at the wrapper level instead of becoming unhandled rejections - unit tests cover all three branches (FetchError silent, SyntaxError silent, unexpected error rethrown) plus the !secret no-double-log contract
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx run ghost:test:ci:integration |
✅ Succeeded | 2m 36s | View ↗ |
nx run ghost:test:integration |
✅ Succeeded | 2m 46s | View ↗ |
nx run-many --target=build --projects=tag:publi... |
✅ Succeeded | 2s | View ↗ |
nx run ghost:test:legacy |
✅ Succeeded | 2m 13s | View ↗ |
nx run ghost:test:e2e |
✅ Succeeded | 2m 25s | View ↗ |
nx run-many -t lint -p ghost |
✅ Succeeded | 34s | View ↗ |
nx run-many -t test:unit -p ghost |
✅ Succeeded | 30s | View ↗ |
nx run @tryghost/admin:build |
✅ Succeeded | 5s | View ↗ |
Additional runs (2) |
✅ Succeeded | ... | View ↗ |
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗
☁️ Nx Cloud last updated this comment at 2026-06-30 12:10:12 UTC
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |

Summary
In the default
pnpm devsetup the sibling ActivityPub container isn't running, but Ghost'sActivityPubService.getWebhookSecret()still tries to hithttp://localhost:2368/.ghost/activitypub/v1/site/on boot. The dev Caddy gateway has noACTIVITYPUB_PROXY_TARGETconfigured, so the request falls through to Ghost's frontend which returns an HTML 404 with status 200.res.json()then throws aSyntaxErrorparsing<!DOCTYPE ..., the catch logsERROR Could not get webhook secret for ActivityPub ..., andinitialiseWebhooks()then logs a secondERROR No webhook secret found - cannot initialise. Result: ~4 ERROR lines per nodemon boot for an expected dev-mode condition.Changes
getWebhookSecret()now discriminates on the error type:FetchError(network failure) andSyntaxError(HTML masquerading as JSON) → log a single INFO with actionable wording and returnnull!secretbranch ininitialiseWebhooks()no longer re-logs — the upstream already covered itactivity-pub-service-wrapper.js'sconfigureActivityPub()got a try/catch so rethrown errors are logged at the wrapper level instead of becoming unhandled promise rejections (previously the all-swallowing catch made this safe)Test plan
FetchErrorsilent,SyntaxErrorsilent, unexpected error rethrown!secretpathpnpm lintclean inghost/coreactivity-pub-service.test.tspassCaddy-side polish (deferred)
The audit also flagged that Caddy could 503
/.ghost/activitypub/*whenACTIVITYPUB_PROXY_TARGETis unset, preventing the HTML-as-JSON fallthrough at the gateway layer. The Ghost-side fix here makes the noise go away regardless of what Caddy returns, so the gateway change is left for a separate PR.