Skip to content

fix(lighthouse): avoid mutating cached preset config#758

Merged
Kikobeats merged 1 commit into
masterfrom
fix/lighthouse-config-mutation
May 17, 2026
Merged

fix(lighthouse): avoid mutating cached preset config#758
Kikobeats merged 1 commit into
masterfrom
fix/lighthouse-config-mutation

Conversation

@Kikobeats
Copy link
Copy Markdown
Member

@Kikobeats Kikobeats commented May 17, 2026

Summary

  • Shallow-copy the preset config object before merging user settings, so the cached import() module export is never mutated across calls
  • Prevents settings from one getConfig() call leaking into subsequent calls using the same preset

Context

import() caches module exports. The previous code assigned config.settings = { ... } directly on the cached object, so user-provided settings (e.g. skipAudits, output) from one request would persist into the next request using the same preset within the same process.

Closes #697

Made with Cursor


Note

Low Risk
Low risk: small, localized change to config construction that avoids mutating imported preset objects; behavior should be identical aside from preventing cross-call settings leakage.

Overview
Fixes get-config to avoid mutating the imported Lighthouse preset config (which can be cached by import()). The function now shallow-copies the preset object and merges user-provided settings into a new config.settings, preventing options from one call leaking into later calls using the same preset.

Reviewed by Cursor Bugbot for commit 1659f40. Bugbot is set up for automated code reviews on this repo. Configure here.

Shallow-copy the preset config before merging user settings so the
cached import() module object is never modified across calls.

Closes #697

Co-authored-by: Cursor <cursoragent@cursor.com>
@coveralls
Copy link
Copy Markdown

Coverage Status

coverage: 74.723% (+0.008%) from 74.715% — fix/lighthouse-config-mutation into master

@Kikobeats Kikobeats merged commit 8b7570b into master May 17, 2026
22 checks passed
@Kikobeats Kikobeats deleted the fix/lighthouse-config-mutation branch May 17, 2026 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Detail Bug] Lighthouse: Custom settings leak across sequential getConfig calls using the same preset

2 participants