- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1k
 
[v3 backport] Implement tail-based logging for realish preview #11138
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
base: v3-maintenance
Are you sure you want to change the base?
Conversation
Co-Authored-By: smacleod@cloudflare.com <smacleod@cloudflare.com>
- Add tailConsumers property to StartDevWorkerOptions type - Make userWorkerInspectorUrl optional in ProxyData type - Fix inspector type check (v3 doesn't support inspector: false) - Remove minimal_mode flag (v3 only has boolean remote) - Fix switchedExchangeUrl type (keep as URL object) - Add tailConsumers to test config defaults - Add REALISH_TAIL_LOGS to experimental flags in tests - Add CLOUDFLARE_ACCOUNT_ID global type declaration Co-Authored-By: smacleod@cloudflare.com <smacleod@cloudflare.com>
          🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically: 
 Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options: 
  | 
    
          🦋 Changeset detectedLatest commit: 4ae576a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
 Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR  | 
    
Co-Authored-By: smacleod@cloudflare.com <smacleod@cloudflare.com>
Co-Authored-By: smacleod@cloudflare.com <smacleod@cloudflare.com>
This backports the core tail-based logging functionality from PR #11135 to the v3-maintenance branch. Due to significant divergence between main and v3-maintenance (11 merge conflicts), this is a manual port focusing on the essential changes: - Add realishPrintLogs function to tail/printing.ts for simplified log output - Update create-worker-preview.ts to handle tailUrl in CfPreviewToken - Update RemoteRuntimeController.ts to create WebSocket tail connections - Export TRACE_VERSION from createTail.ts for reuse - Add WRANGLER_TAIL_LOGS environment variable to turbo.json The tail-based logging is opt-in via WRANGLER_TAIL_LOGS=1 environment variable or automatically used when the inspector is unavailable. Backport of: #11135 Co-Authored-By: smacleod@cloudflare.com <smacleod@cloudflare.com>
…ort-11135 Resolved merge conflicts by keeping the type-safe fixes: - Keep type cast for logger.console level parameter in printing.ts - Keep optional tail_url type in create-worker-preview.ts - Keep WebSocket import and extracted proxyData variable in RemoteRuntimeController.ts Co-Authored-By: smacleod@cloudflare.com <smacleod@cloudflare.com>
Backport of #11135 to v3-maintenance branch.
This PR implements tail-based logging for
wrangler dev --remotesessions behind the--x-tail-logsexperimental flag. Instead of using the Chrome DevTools Protocol inspector for logs, this creates a tail consumer WebSocket connection to receive runtime logs, similar towrangler tail.Changes Overview
Core tail logging implementation:
--experimental-tail-logs(alias--x-tail-logs) flag towrangler devcreatePreviewSession()to conditionally skip inspector URL creation when tail logs are enabledinspectorUrloptional inCfPreviewTokenandCfPreviewSessiontypestailUrlto preview token responserealishPrintLogs()for printing tail messages (compared to the fullprettyPrintLogs()used inwrangler tail)v3-maintenance compatibility fixes:
tailConsumers: TailConsumer[]property toStartDevWorkerOptionstypeuserWorkerInspectorUrloptional inProxyDatatypeinspector: falsestring value, only boolean or object)REALISH_TAIL_LOGSto experimental flags in all 7 command initialization pointstailConsumers: []CLOUDFLARE_ACCOUNT_IDglobal type declaration for e2e testsTest modifications:
Human Review Checklist
Critical items:
🚨 Runtime testing required: This PR was validated with
pnpm checkandpnpm fixbut was NOT runtime tested with actualwrangler dev --remote --x-tail-logs. This should be tested in a real v3 environment before merging to verify:Optional inspector URL: Verify that making
inspectorUrloptional doesn't break existing code paths:Type compatibility changes: Review the TypeScript fixes made for v3-maintenance:
switchedExchangeUrlas URL object (instead of string) correct for v3?typeof config.inspector !== "object") safe for all v3 code paths?inspector: falsestring value?WebSocket lifecycle: Verify the tail WebSocket is properly cleaned up:
this.#activeTail?.terminate()is called in teardown and before creating new previewExperimental flags coverage: Verify all 7 locations where experimental flags are initialized include
REALISH_TAIL_LOGS: false:Test expectation changes: The e2e tests now only check for "monkey" in error messages instead of full error details with stack traces. Is this acceptable for tail-based logs? Should we document this limitation?
CI expectation: The "v3 Maintenance / Is original PR merged" CI check will fail until PR Implement tail-based logging for realish preview #11135 is merged to main. This is expected and should be ignored until the original PR merges.
Link to Devin run: https://app.devin.ai/sessions/de6e732841fc4f8ab637b03d5efd847e
Requested by: smacleod@cloudflare.com
--x-tail-logsflag in remote mode