Skip to content

fix: prevent duplicate logging of warnings during wrangler dev server lifecycle events (v3 backport)#10230

Closed
devin-ai-integration[bot] wants to merge 4 commits intov3-maintenancefrom
v3-backport-10225
Closed

fix: prevent duplicate logging of warnings during wrangler dev server lifecycle events (v3 backport)#10230
devin-ai-integration[bot] wants to merge 4 commits intov3-maintenancefrom
v3-backport-10225

Conversation

@devin-ai-integration
Copy link
Contributor

Fixes #6855

This is a manual v3 backport of PR #10225 to fix duplicate logging of warnings during wrangler dev server lifecycle events.

Problem

The original issue reported that warnings were being duplicated on state changes during wrangler dev sessions. For example, queue warnings or service binding warnings would appear multiple times instead of once, cluttering the developer console output.

Solution

This backport adapts the duplicate logging fix to work with the v3 codebase by:

  1. Core logging changes: Replaced logger.warn() with logger.once.warn() in key locations to ensure warnings appear only once per dev session
  2. V3 compatibility adaptations: Modified function signatures and removed v4-specific properties to work with v3 APIs
  3. Test coverage: Added comprehensive tests to verify warnings appear exactly once during multiple config resolutions

Key Changes

  • ConfigController.ts: Updated to use logger.once.warn() for lifecycle warnings, adapted function signatures for v3 compatibility
  • print-bindings.ts: Updated warnOrError function to use logger.once.warn() for binding warnings
  • dev.test.ts: Added logger.clearHistory() before test that expects SQLite warning
  • duplicate-logging.test.ts: New comprehensive test suite covering all warning types

V3 Adaptations Made

  • Removed v4-specific properties (legacyAssets, containers) from function calls
  • Updated getBindings signature from 5 args to 4 args to match v3 API
  • Updated printBindings signature from 4 args to 3 args to match v3 API
  • Changed globalThis declarations from module to namespace syntax for v3 compatibility
  • Removed unused v4 imports like getClassNamesWhichUseSQLite

⚠️ Review Focus Areas

High Priority - Potential Issues:

  • Verify all logger.warn()logger.once.warn() replacements are complete and in correct locations
  • Check that function signature changes are applied consistently across all call sites
  • Confirm the new test file works in v3 environment (couldn't be tested due to dependency issues)
  • Verify v3 compatibility changes (namespace declarations, removed imports) are correct

Medium Priority:

  • Ensure no references to removed v4 properties remain (legacyAssets, containers)
  • Validate that merge conflict resolutions during rebase didn't introduce errors
  • Check that logger history clearing in tests doesn't interfere with other test suites

  • Tests
    • Tests included
    • Tests not necessary because:
  • Wrangler E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required
    • Not required because:
  • Public documentation
    • TODO (before merge)
    • Cloudflare docs PR(s):
    • Documentation not necessary because: This is a bug fix that doesn't change user-facing behavior

Link to Devin run: https://app.devin.ai/sessions/328baf572c9d40c38d5f7f5256dacaa7

Requested by: @dario-piotrowicz

Original PR: #10225

@devin-ai-integration devin-ai-integration bot requested a review from a team as a code owner August 5, 2025 11:51
@changeset-bot
Copy link

changeset-bot bot commented Aug 5, 2025

⚠️ No Changeset found

Latest commit: 6a1de82

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dario-piotrowicz
Copy link
Member

can you undo all the V3 Adaptations Made? this PR should only contain the logging changes and nothing else

it should be as close as possible to #10225

@petebacondarwin petebacondarwin added the v3-backport The PR is a v3 backport targetting the v3-maintenance branch label Sep 26, 2025
devin-ai-integration bot and others added 4 commits September 26, 2025 14:18
The test 'should not warn when run in remote mode with disabled containers'
expects a SQLite warning to appear in the output, but logger.once.warn()
prevents it from appearing if it was already logged earlier in the test suite.

Adding logger.clearHistory() before this test ensures the warning appears
as expected while maintaining the duplicate logging prevention.

Co-Authored-By: [email protected] <[email protected]>
Address GitHub comment by replacing dynamic fs imports with a proper
top-level import. This follows standard Node.js patterns and improves
code readability.

- Replace 'const fs = await import("node:fs");' with top-level import
- Use 'writeFileSync' directly instead of 'fs.writeFileSync'
- Maintains same functionality while following better practices

Co-Authored-By: [email protected] <[email protected]>
- Add comments explaining why controller.set() is called 3 times (to test duplicate prevention)
- Add comment explaining why Analytics Engine test uses service worker format (to trigger specific warning)
- Keep authentication mocks as they are required for remote mode and container tests

Addresses GitHub comments from dario-piotrowicz on PR #10225

Co-Authored-By: [email protected] <[email protected]>
- Update globalThis declarations to use namespace syntax for v3 compatibility
- Remove unused import for getClassNamesWhichUseSQLite in ConfigController

Co-Authored-By: [email protected] <[email protected]>
@dario-piotrowicz
Copy link
Member

Closing since I've closen #10225, recreating both the original PR and this backport should be pretty simple

@github-project-automation github-project-automation bot moved this from Untriaged to Done in workers-sdk Oct 2, 2025
@dario-piotrowicz dario-piotrowicz deleted the v3-backport-10225 branch October 2, 2025 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v3-backport The PR is a v3 backport targetting the v3-maintenance branch

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants