You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Title: Race Condition: Incorrect AbortController Status Check During Tab Visibility Changes
Description
Bug Report
When rapidly switching browser tabs with openWhenHidden: false, the error handling logic incorrectly checks the abort status of a new request instead of the aborted one, leading to unnecessary retries.
Steps to Reproduce
Create an EventSource connection with openWhenHidden: false
Quickly switch to another tab and back
Observe the network requests in DevTools
Current Behavior
Initial request (A) starts with AbortController instance A
Tab becomes hidden -> Controller A's abort() is called
Tab becomes visible -> New request (B) starts with Controller B
Request A's error handler executes but checks Controller B's status
Since Controller B is not aborted, it triggers unnecessary retry
Expected Behavior
The error handler should check the abort status of the controller that initiated the request, not the current global controller instance.
Technical Details
The issue occurs because:
curRequestController is shared across async contexts
Error handling happens asynchronously after the controller reference has changed
This leads to checking the wrong controller's abort status
Impact
Unnecessary network requests
Incorrect error handling
Potential performance issues with rapid tab switching
Environment
Browser: All major browsers
Package Version: v2.0.1 (Latest version)
OS: All platforms
Suggested Fix
Store the AbortController instance in function scope to ensure error handling uses the correct instance for status checking.
Title: Race Condition: Incorrect AbortController Status Check During Tab Visibility Changes
Description
Bug Report
When rapidly switching browser tabs with
openWhenHidden: false
, the error handling logic incorrectly checks the abort status of a new request instead of the aborted one, leading to unnecessary retries.Steps to Reproduce
openWhenHidden: false
Current Behavior
Expected Behavior
The error handler should check the abort status of the controller that initiated the request, not the current global controller instance.
Technical Details
The issue occurs because:
curRequestController
is shared across async contextsImpact
Environment
Suggested Fix
Store the AbortController instance in function scope to ensure error handling uses the correct instance for status checking.
Pull Request
#94
The text was updated successfully, but these errors were encountered: