fix: harden world travel polling

This commit is contained in:
Bastian Wagner
2026-08-18 21:52:54 +02:00
parent 610c404759
commit a738c61611
3 changed files with 217 additions and 17 deletions

View File

@@ -71,3 +71,53 @@ there is no repository-configured lint command to run for this task.
this task explicitly prohibited subagents. The implementation was instead
reviewed directly against the task brief and verified through the focused and
complete web test/build checks above.
## Review fix round 1
### Findings addressed
- A journey whose `arrivesAt` was already in the past made an immediate poll
but also installed a countdown interval. This could overlap an outstanding
request.
- A late response after store destruction could still apply state and start
follow-on work.
The store now makes a single immediate poll at local zero with no countdown
interval. It uses one in-flight poll at a time and schedules a deliberate
one-second retry when the server still returns `TRAVELLING` or a poll fails.
All late async continuations check the destroy flag before changing state or
scheduling timers. The browser still never declares arrival or changes the
location itself.
### TDD evidence
```powershell
npm test --workspace=@ashen-realms/web -- --watch=false --include='src/app/features/world/world.store.spec.ts'
```
RED result: 2 of 9 tests failed against the previous implementation. The
already-expired test observed three calls where a pending request must allow
only two, and the destroy test observed an unwanted second character/location
reload after a late `COMPLETED` response.
GREEN result: 1 test file passed, 9 tests passed. The expanded cases establish
that `IDLE` and continuing `TRAVELLING` do not reload authoritative character
or location data, expired/skewed client time remains single-flight/throttled,
a transient poll error retries and recovers, and destruction ignores a late
response.
### Fresh verification
```powershell
npm test --workspace=@ashen-realms/web -- --watch=false
# 3 test files passed, 13 tests passed
npm run build:web
# Angular production build completed successfully
npm exec --workspace=@ashen-realms/web -- prettier --check <Task-7 files>
# All matched files use Prettier code style
git diff --check -- <Task-7 files>
# exit 0
```