fix(DNR): prevent hanging on DNR APIs after optional permissions#411
fix(DNR): prevent hanging on DNR APIs after optional permissions#411qixing-jk wants to merge 2 commits into
Conversation
- Add timeout utility for Promises that may never settle - Wrap DNR updateSessionRules with timeout and retry logic - Ensure tests verify timeout behavior
- Move DNR constants to shared module - Replace hardcoded values with imported constants - Derive TIME_BUDGET_MS from TIMEOUT and MAX_ATTEMPTS - Update AUTO_DETECT_SLOW_HINT_DELAY_MS to use TIME_BUDGET_MS
WalkthroughThe changes introduce timeout and retry mechanisms for DNR (Declarative Net Request) session rules operations. A new constants module defines timeout/retry parameters, utility functions provide promise timeout handling, the cookie injection logic integrates these timeouts with error classification, and tests verify the timeout behavior. Changes
Sequence DiagramsequenceDiagram
participant Client as applyTempWindowCookieRule
participant Safe as updateSessionRulesSafe
participant Timeout as withTimeout
participant DNR as chrome.declarativeNetRequest
Client->>Safe: Call with rules
activate Safe
Safe->>Timeout: Wrap updateSessionRules call with timeout
activate Timeout
Timeout->>DNR: updateSessionRules(rules)
activate DNR
alt Success
DNR-->>Timeout: Resolves
Timeout-->>Safe: Returns result
else Timeout
Note over Timeout: TimeoutError thrown
Timeout-->>Safe: Rejects with timeout
Safe->>Safe: Classify as timeout (retry)
else Permission Error
DNR-->>Timeout: Rejects with permission error
Timeout-->>Safe: Rejects with permission error
Safe->>Safe: Classify as permission (no retry)
end
deactivate DNR
deactivate Timeout
Safe-->>Client: Returns ruleId or null
deactivate Safe
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Preview build ready for commit Artifacts:
Download from workflow run: https://github.com/qixing-jk/all-api-hub/actions/runs/21543851548 This build is for review only and is not released. |
#359
Summary by CodeRabbit
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.