Skip to content

feat: Log warnings once - #2536

Merged
aklinker1 merged 6 commits into
wxt-dev:mainfrom
fkatsuhiro:feat/logger-once
Aug 1, 2026
Merged

feat: Log warnings once#2536
aklinker1 merged 6 commits into
wxt-dev:mainfrom
fkatsuhiro:feat/logger-once

Conversation

@fkatsuhiro

Copy link
Copy Markdown
Contributor

Overview

  • Wrapped wxt.logger with createWxtLogger to add warnOnce (the Logger type itself stays unchanged)
  • The dedup Set is created once in registerWxt and delegates through a closure that always reads the current wxt.config.logger
  • State persists across reloadConfig(), so manifest.ts warnings no longer repeat on dev-server restarts

Manual Testing

warnOnce

  • Calling it repeatedly with the same arguments logs to the underlying warn only once, on the first call, with those exact arguments
  • Calling it with distinct arguments logs each one independently, once per distinct message
  • Regular warn calls are unaffected by dedup — they always pass through to the underlying warn every time
  • If the underlying logger instance is swapped out mid-life (simulating wxt.reloadConfig() replacing wxt.config.logger), the same message still isn't re-logged, while a genuinely new message is correctly delivered to the new underlying logger

delegation

  • debug/ log / info / error / fatal / success are all passed straight through to the underlying logger
  • Reading and writing level is reflected on the underlying logger
image

Related Issue

This PR closes #2507

@fkatsuhiro
fkatsuhiro requested a review from aklinker1 as a code owner July 30, 2026 15:25
@netlify

netlify Bot commented Jul 30, 2026

Copy link
Copy Markdown

Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit e6e318d
🔍 Latest deploy log https://app.netlify.com/projects/creative-fairy-df92c4/deploys/6a6e127e0a188500083c2b4d
😎 Deploy Preview https://deploy-preview-2536--creative-fairy-df92c4.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added the pkg/wxt Includes changes to the `packages/wxt` directory label Jul 30, 2026

@aklinker1 aklinker1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good other than the callback setup you're using. It adds a bit of overhead every time wxt.logger is accessed - see comments for recommended changes

Comment thread packages/wxt/src/core/wxt.ts Outdated
Comment thread packages/wxt/src/core/wxt.ts Outdated
@fkatsuhiro fkatsuhiro changed the title Feat/logger once Feat: logger once use warnOnce Aug 1, 2026
@fkatsuhiro

Copy link
Copy Markdown
Contributor Author

Looks good other than the callback setup you're using. It adds a bit of overhead every time wxt.logger is accessed - see comments for recommended changes

Thank you for review this PR. Let me update it. Thank you.

@aklinker1 aklinker1 changed the title Feat: logger once use warnOnce feat: logger once use warnOnce Aug 1, 2026
@aklinker1 aklinker1 changed the title feat: logger once use warnOnce feat: Log warnings once Aug 1, 2026

@aklinker1 aklinker1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cleaned up the tests a little - mocked dependencies for the resolve-config.test.ts (e2e tests setup directories, not unit), and used mock instead of fully defining a fake logger instance. I also changed the logic to share the warn set between all instances of WxtLogger, not per-instance.

@pkg-pr-new

pkg-pr-new Bot commented Aug 1, 2026

Copy link
Copy Markdown

Open in StackBlitz

@wxt-dev/analytics

npm i https://pkg.pr.new/@wxt-dev/analytics@2536

@wxt-dev/auto-icons

npm i https://pkg.pr.new/@wxt-dev/auto-icons@2536

@wxt-dev/browser

npm i https://pkg.pr.new/@wxt-dev/browser@2536

@wxt-dev/i18n

npm i https://pkg.pr.new/@wxt-dev/i18n@2536

@wxt-dev/is-background

npm i https://pkg.pr.new/@wxt-dev/is-background@2536

@wxt-dev/module-react

npm i https://pkg.pr.new/@wxt-dev/module-react@2536

@wxt-dev/module-solid

npm i https://pkg.pr.new/@wxt-dev/module-solid@2536

@wxt-dev/module-svelte

npm i https://pkg.pr.new/@wxt-dev/module-svelte@2536

@wxt-dev/module-vue

npm i https://pkg.pr.new/@wxt-dev/module-vue@2536

@wxt-dev/runner

npm i https://pkg.pr.new/@wxt-dev/runner@2536

@wxt-dev/storage

npm i https://pkg.pr.new/@wxt-dev/storage@2536

@wxt-dev/unocss

npm i https://pkg.pr.new/@wxt-dev/unocss@2536

@wxt-dev/webextension-polyfill

npm i https://pkg.pr.new/@wxt-dev/webextension-polyfill@2536

wxt

npm i https://pkg.pr.new/wxt@2536

commit: e6e318d

@aklinker1
aklinker1 enabled auto-merge (squash) August 1, 2026 15:36
@codecov

codecov Bot commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.45455% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 79.37%. Comparing base (186beab) to head (e6e318d).

Files with missing lines Patch % Lines
packages/wxt/src/core/resolve-config.ts 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2536      +/-   ##
==========================================
+ Coverage   79.18%   79.37%   +0.19%     
==========================================
  Files         133      134       +1     
  Lines        3982     3996      +14     
  Branches      923      924       +1     
==========================================
+ Hits         3153     3172      +19     
+ Misses        733      729       -4     
+ Partials       96       95       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aklinker1
aklinker1 merged commit accf458 into wxt-dev:main Aug 1, 2026
18 checks passed
@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Thanks for helping make WXT better!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg/wxt Includes changes to the `packages/wxt` directory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce Logger#warnOnce

2 participants