Unawaited state updates in web settings and remote-assignment tests throw after happy-dom teardown under high worker concurrency

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
react, tailwindcss, typescript
领域
testing-qa

调研方向

Start with the two test files named in the issue: apps/web/src/routes/_app/admin/tests/settings.test.tsx (the autosave onSuccess timer and the unmount effect around settings.tsx:161-166) and apps/web/src/routes/_app/session/tests/remote-assignment.test.tsx at the two redirect-URL tests near lines 238 and 250. Reproduce by running the apps/web unit tests under high worker concurrency. Done means the timer is cleared on unmount or the tests wait for the post-submit state to settle, with no uncaught window errors across repeated runs.

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

描述

Area: Web Bug Difficulty: Low Priority: Low

Under high Vitest worker concurrency (reproduced on a 32-core Linux host where pnpm test:coverage spawns 31 workers), two apps/web unit test files intermittently fail the run with an uncaught ReferenceError: window is not defined inside React (resolveUpdatePriority in react-dom-client.development.js:944:7) when a state update fires after happy-dom has torn down window:

  1. apps/web/src/routes/_app/admin/settings.tsx:92 (apps/web/src/routes/_app/admin/__tests__/settings.test.tsx): autosave's onSuccess callback schedules savedTimerRef.current = setTimeout(() => setSaveState('idle'), 2000), and the unmount useEffect at lines 161–166 clears durationDebounceRef.current without clearing savedTimerRef.current. Under worker contention, worker teardown can cross the 2s mark and run setSaveState('idle') after window is gone.
  2. apps/web/src/routes/_app/session/__tests__/remote-assignment.test.tsx:238,250: both redirect-URL tests call submitForm() and return as soon as await waitFor(() => expect(mocks.mutateAsync).toHaveBeenCalled()) passes, before onSubmit and @douglasneuroinformatics/libui's Form handleSubmit (Form.js:87:13) finish their post-submit setState microtasks (compare createAssignment at line 124, which waits for the rendered Assignment Link).
主要语言
TypeScript
星标
119
派生
19
平均合并
1 天 18 小时
30 天内合并 PR
61

环境准备

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

从这里开始

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

DouglasNeuroInformatics/OpenDataCapture 的其他 Issue

查看 DouglasNeuroInformatics/OpenDataCapture 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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