Skip to content

fix: prevent stale header rules with versioned storage meta#88

Open
Kirrrusha wants to merge 9 commits intomainfrom
fix/update-request-with-tab-windows
Open

fix: prevent stale header rules with versioned storage meta#88
Kirrrusha wants to merge 9 commits intomainfrom
fix/update-request-with-tab-windows

Conversation

@Kirrrusha
Copy link
Collaborator

Summary

Исправляет Windows-специфичную гонку, когда при переключении вкладок и редактировании заголовков могли применяться устаревшие значения (старый снапшот из storage), перезаписывая актуальную конфигурацию.

Changes

  • Атомарное обновление DNR-правил: применяем declarativeNetRequest.updateDynamicRules({ removeRuleIds, addRules }) одним вызовом, чтобы избежать гонки remove→add.
  • Сериализация применения в background: добавлена очередь (single-flight), которая склеивает параллельные триггеры и гарантирует “latest wins”.
  • Строгая версия конфигурации: сохраняем headersConfigMetaV1 (seq, монотонный updatedAt) и в background пропускаем устаревшие снапшоты, даже если события приходят не по порядку.
  • Убрано лишнее применение на смене вкладки: DNR-правила глобальные, поэтому пересборка на tabs.onActivated только увеличивала вероятность гонок.
  • Убран legacy reload-путь: удалены updateOverrideHeaders/runtime reload message; обновления теперь идут через storage.onChanged.

Why this works

На Windows из-за другой латентности и планирования событий чаще происходили перекрывающиеся триггеры применения правил. Версионирование + очередь не позволяют применить старую конфигурацию “после” новой.

Test plan

  • pnpm test:unit
  • Ручная проверка (Windows):
    • Менять значения заголовков в popup и быстро переключать вкладки (несколько раз).
    • Проверить, что запросы уходят с последними значениями заголовков.
    • В логах background убедиться, что устаревшие снапшоты пропускаются (Apply skipped (stale meta)), а применения идут последовательно.

Notes

  • seq — best-effort при конкурентных записях; updatedAt принудительно монотонный и используется как tie-breaker.

github-actions bot added a commit that referenced this pull request Jan 23, 2026
github-actions bot added a commit that referenced this pull request Jan 23, 2026
@github-actions
Copy link

github-actions bot commented Jan 23, 2026

github-actions bot added a commit that referenced this pull request Jan 23, 2026
github-actions bot added a commit that referenced this pull request Jan 30, 2026
github-actions bot added a commit that referenced this pull request Jan 30, 2026
github-actions bot added a commit that referenced this pull request Jan 30, 2026
github-actions bot added a commit that referenced this pull request Feb 2, 2026
github-actions bot added a commit that referenced this pull request Feb 2, 2026
github-actions bot added a commit that referenced this pull request Feb 2, 2026
github-actions bot added a commit that referenced this pull request Feb 4, 2026
github-actions bot added a commit that referenced this pull request Feb 4, 2026
github-actions bot added a commit that referenced this pull request Feb 4, 2026
github-actions bot added a commit that referenced this pull request Feb 6, 2026
github-actions bot added a commit that referenced this pull request Feb 6, 2026
github-actions bot added a commit that referenced this pull request Feb 6, 2026
@Kirrrusha Kirrrusha force-pushed the fix/update-request-with-tab-windows branch from 13f91af to 1585555 Compare February 6, 2026 07:28
github-actions bot added a commit that referenced this pull request Feb 6, 2026
github-actions bot added a commit that referenced this pull request Feb 6, 2026
github-actions bot added a commit that referenced this pull request Feb 6, 2026
@Kirrrusha Kirrrusha force-pushed the fix/update-request-with-tab-windows branch from 1585555 to c7d6752 Compare February 6, 2026 07:56
github-actions bot added a commit that referenced this pull request Feb 6, 2026
github-actions bot added a commit that referenced this pull request Feb 6, 2026
github-actions bot added a commit that referenced this pull request Feb 6, 2026
@Kirrrusha Kirrrusha force-pushed the fix/update-request-with-tab-windows branch from c7d6752 to 92e9ea1 Compare February 6, 2026 08:14
github-actions bot added a commit that referenced this pull request Feb 6, 2026
github-actions bot added a commit that referenced this pull request Feb 6, 2026
github-actions bot added a commit that referenced this pull request Feb 6, 2026
@Kirrrusha Kirrrusha force-pushed the fix/update-request-with-tab-windows branch from 92e9ea1 to 386a76a Compare February 9, 2026 14:16
Kirill Lebedenko and others added 6 commits February 9, 2026 17:26
- Add retry logic (3 attempts with exponential backoff) for transient
  DNR updateDynamicRules errors ("Internal error while updating dynamic rules")
- Re-throw errors from setBrowserHeaders to prevent queue state from updating
  when rules fail to apply
- Add detailed diagnostic logging for debugging header toggle issues
Co-authored-by: Cursor <cursoragent@cursor.com>
@Kirrrusha Kirrrusha force-pushed the fix/update-request-with-tab-windows branch from 386a76a to 3c192ee Compare February 9, 2026 14:41
github-actions bot added a commit that referenced this pull request Feb 9, 2026
github-actions bot added a commit that referenced this pull request Feb 9, 2026
github-actions bot added a commit that referenced this pull request Feb 9, 2026
…ggle Route all startup/install applies through the queue fallback path and serialize diagnostic payloads as stable JSON strings to simplify production incident analysis Add an opt-in UI toggle that mirrors extension logs into the active page console for faster user-side debugging
github-actions bot added a commit that referenced this pull request Feb 12, 2026
github-actions bot added a commit that referenced this pull request Feb 12, 2026
github-actions bot added a commit that referenced this pull request Feb 12, 2026
…sed self-healing for long-running apply drift and expose a user-triggered debug log export so support can collect worker health storage state DNR snapshots and recent logs in a single file Also temporarily comment out CI e2e container commands while race diagnostics are in progress
@Kirrrusha Kirrrusha force-pushed the fix/update-request-with-tab-windows branch from 4b9e608 to f564bb9 Compare February 13, 2026 07:57
github-actions bot added a commit that referenced this pull request Feb 13, 2026
github-actions bot added a commit that referenced this pull request Feb 13, 2026
github-actions bot added a commit that referenced this pull request Feb 13, 2026
…y on every background worker boot so DNR rules are immediately synced with storage after sleep/unlock style restarts Add an e2e regression that injects a stale rule reloads the extension and verifies stale rules are cleared when headers are disabled
github-actions bot added a commit that referenced this pull request Feb 13, 2026
github-actions bot added a commit that referenced this pull request Feb 13, 2026
github-actions bot added a commit that referenced this pull request Feb 13, 2026
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.

1 participant