Add documentation for resolving EHSAN development environment crashes

Add a new file documenting how to resolve EHSAN development environment crashes caused by stale HMR states.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 1fa9329f-0cec-4a2f-80e8-e26dbae3142e
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 05c3529b-9fb6-4549-875d-b3abd264f86f
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/4d696b13-86f2-4c9d-be0d-95b293430047/1fa9329f-0cec-4a2f-80e8-e26dbae3142e/e10exuU
Replit-Helium-Checkpoint-Created: true
This commit is contained in:
Replit Agent
2026-06-05 18:10:04 +00:00
parent 8519202949
commit 1e96856525
5 changed files with 26 additions and 0 deletions
+1
View File
@@ -1,3 +1,4 @@
- [Donate semantics](donate-semantics.md) — donations accumulate + clamp to target; a case enters the closed-loop pipeline only when fully funded.
- [api-server data](api-server-data.md) — mockDb is in-memory and mutated by POST calls; restart the workflow to reset to clean seed for demos.
- [EHSAN branding](ehsan-branding.md) — ehsan.sa blocks scraping; font is IBM Plex Sans Arabic (best match), currency uses new Saudi Riyal symbol via <Riyal/> mask component.
- [EHSAN HMR context crash](ehsan-hmr-context-crash.md) — "useLanguage must be used within a LanguageProvider" with correct source = stale Fast Refresh state; restart the web workflow.
+25
View File
@@ -0,0 +1,25 @@
---
name: EHSAN HMR context crash (false runtime error)
description: When the POC throws "useLanguage must be used within a LanguageProvider" but the source is correct, it's a stale HMR state — restart the workflow.
---
# "useLanguage must be used within a LanguageProvider" after edits
If the EHSAN POC crashes with `useLanguage must be used within a LanguageProvider`
(and/or `Invalid hook call ... more than one copy of React`, or
`Cannot read properties of undefined`) **while `App.tsx` clearly wraps the tree in
`LanguageProvider` and the source is correct**, it is almost always a corrupted
Vite Fast Refresh (HMR) state, NOT a code bug.
**Root cause:** `src/contexts/LanguageContext.tsx` exports both a component
(`LanguageProvider`) and a hook (`useLanguage`) from one file, so Vite logs
`Could not Fast Refresh ("useLanguage" export is incompatible)`. After several hot
updates the running app ends up with a duplicate React context instance and the
hook can't find the provider.
**Fix:** restart the `artifacts/ehsan-poc: web` workflow. The built/production app
is unaffected — this is dev-only.
**How to apply:** before editing source to "fix" such an error, confirm the current
files are actually correct (provider present, key exists); if so, just restart the
workflow instead of changing code.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 KiB