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

Open
#1,915 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
react, tailwindcss, typescript
Domain
testing-qa

Research direction

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.

Written by the indexing model from the issue text.

Description

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).
Dominant language
TypeScript
Stars
119
Forks
19
Avg merge
1d 18h
Merged PRs (30d)
61

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from DouglasNeuroInformatics/OpenDataCapture

All issues in DouglasNeuroInformatics/OpenDataCapture

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.