Repository navigation
Turn off Workers invocation logs so raw session IDs aren't stored - #74
Conversation
The notification WebSocket sends the session ID in its URL, and invocation logs record every request's URL and headers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017dqWu3YgeVRGwBt5pXDq4A
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpdates Wrangler configuration to disable automatic Workers invocation logs, preventing raw PHPSESSIDs in notification WebSocket URLs from being stored while preserving application logs and request analytics. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Sourcery assessment
Needs a human reviewer. If disabling invocation logs is the wrong call, request URLs and headers will be unavailable for troubleshooting and incident investigation during the affected period, and those records cannot be recreated after reverting. Reverting restores future invocation logging, while the change does not alter user data, access decisions, or application behavior.
Replaces the invocation logs turned off in the previous commit: method, path, status, duration, colo and country, plus the error on failure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017dqWu3YgeVRGwBt5pXDq4A
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017dqWu3YgeVRGwBt5pXDq4A
Why
#72 stopped our own log lines from printing raw PHPSESSIDs, but Cloudflare still stores them. The userscript opens the notification WebSocket as
/ws/notifications?SessionID=<PHPSESSID>, and Workers Logs' automatic invocation logs record every request's URL and headers (docs). A livewrangler tailafter #73 deployed showed the raw session ID in that URL.Moving the session into a header (e.g.
Sec-WebSocket-Protocol) wouldn't help, because headers are logged too. It would also need a userscript release, and old versions would keep sending the URL anyway.What
Output.*/console.*lines are still stored. After fix: stop logging raw PHPSESSID values #72 they contain only a 16-character hash prefix of the session.logdb) stores IP, endpoint, script version and username, with no session.To keep debugging, the worker now writes its own line for every request (
RequestLogLineinindex.ts):{"method":"GET","path":"/ws/notifications","status":101,"durationMs":12,"colo":"HKG","country":"CN"}It's a JSON object, so Workers Logs indexes each field, and you can filter by
path,statusand so on in the dashboard. A request that throws is logged withconsole.error, including the error, and then rethrown. The line never includes the query string or headers.What we still lose: request headers (user agent etc.) and Cloudflare's per-invocation CPU time and outcome. CPU-limit and crash counts still show in the worker's Metrics tab.
Raw session IDs already in Workers Logs age out with Cloudflare's retention (3 days on Free, 7 on Paid).
Checks
npm test: 147 pass, including 3 new tests that check the log line never contains the query string.wrangler deploy --dry-runbuilds. I checked our own log lines:Fetch:prints only xmoj.tech page URLs (the session goes in a Cookie header, which isn't logged), andprocessCppStringonly sees public std code.🤖 Generated with Claude Code
https://claude.ai/code/session_017dqWu3YgeVRGwBt5pXDq4A
Summary by Sourcery
Disable automatic Workers invocation logs and replace them with privacy-safe request logging to prevent raw session IDs from being stored.
Bug Fixes:
Enhancements:
Deployment:
Tests: