Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Race Condition: Incorrect AbortController Status Check During Tab Visibility Changes

未关闭
#95 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

@yushihang 已经在做这个了。

开始于 2025年3月11日。

  • #94 来自 @yushihang —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
typescript
领域
frontend

调研方向

首先在 TypeScript 源代码中搜索 curRequestController 和 openWhenHidden 的可见性处理逻辑。跟踪请求错误回调,并确认它保留了启动该请求的控制器;重现快速切换标签页的情况,并确认被中止的请求不会触发不必要的重试。

由索引模型根据 Issue 内容生成。

描述

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
  1. Create an EventSource connection with openWhenHidden: false
  2. Quickly switch to another tab and back
  3. Observe the network requests in DevTools
Current Behavior
  1. Initial request (A) starts with AbortController instance A
  2. Tab becomes hidden -> Controller A's abort() is called
  3. Tab becomes visible -> New request (B) starts with Controller B
  4. Request A's error handler executes but checks Controller B's status
  5. 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.

Pull Request

https://github.com/Azure/fetch-event-source/pull/94

主要语言
TypeScript
星标
2.9k
派生
197
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Azure/fetch-event-source 的其他 Issue

查看 Azure/fetch-event-source 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。