Skip to content

Say what failed: no network, and a session that expired mid-work - #47

Merged
yt314 merged 1 commit into
mainfrom
say-why-it-failed
Sep 18, 2026
Merged

yt314 merged 1 commit into
mainfrom
say-why-it-failed

Conversation

@yt314

@yt314 yt314 commented Sep 18, 2026 •

Copy link
Copy Markdown
Owner

Two cases where the system knew what had happened — and did not say so.

1. No network

A teacher marks a finished lesson from her phone and the wifi drops. What she saw until now:

AFTER SAVE WITH NO NETWORK: … העדכון נכשל …
MENTIONS CONNECTION? NO

"The update failed" leaves open exactly the question that matters: was the change saved or not? When the request never reached the server at all, Angular returns status 0 with no response body, and that can be said outright:

BLOCKED: POST /api/lessons/…/complete
TOAST: "שגיאה  אין חיבור לשרת. בדקי את החיבור לאינטרנט ונסי שוב."

That both explains what happened and says what to do about it. The fix sits in extract-error-message.ts — the function every screen already routes its errors through — so the whole app gets it at once.

2. The session expired mid-work

A teacher inside the payments screen, token expired, refresh failed:

SHE IS ON  : http://localhost:4200/app/payments
LANDED ON  : http://localhost:4200/login
ANY REASON GIVEN? NO

A blank login form, no reason, no way back. The interesting part: the capability already existed in the code. auth.guard.ts adds returnUrl, idle-logout.service.ts adds timeout=1 and the login screen explains "you were logged out for inactivity". Only auth.interceptor.ts — the one path of the three that fires while she is working — used neither.

After the fix:

LANDED ON  : http://localhost:4200/login?expired=1&returnUrl=%2Fapp%2Fpayments
SCREEN SAYS: … ההתחברות פגה. יש להתחבר שוב — ונחזיר אותך למקום שבו היית. …
ANY REASON GIVEN? yes

A deliberate decision: the route guard stays silent

auth.guard.ts does not get expired=1, on purpose. It also fires on a first visit to a bookmark or a shared link, and there "your session expired" would simply be untrue. Only the interceptor path guarantees there was a session and that it ended.

Testing

  • npx ng build — clean.
  • npx vitest run — 30 passing, including a new spec for extract-error-message covering status 0, a 409 carrying a real message (so it is not mistaken for a lost connection), a controller message, an errors array, a ProblemDetails errors dictionary, and the fallback. (app.spec.ts fails on main too — unrelated.)
  • Both scenarios were reproduced in the browser before and after, using page.route to drop the network and to return 401.

Demo data untouched — 4 teachers, 3 students.

שני מקרים שבהם המסך ידע מה קרה ולא אמר:

1. כשאין רשת, Angular מחזיר status 0 בלי גוף תשובה, וההודעה שהוצגה
   הייתה הנוסח הכללי ("העדכון נכשל"). זה משאיר פתוחה את השאלה אם
   השינוי נשמר. עכשיו: "אין חיבור לשרת. בדקי את החיבור לאינטרנט ונסי
   שוב." — גם מסביר מה קרה וגם אומר מה לעשות.

2. כשההפעלה פגה באמצע עבודה, רענון הטוקן נכשל והמשתמשת נזרקה למסך
   התחברות ריק, בלי סיבה ובלי חזרה למקום שבו הייתה. היכולת כבר קיימת
   בקוד — שומר המסלול מוסיף returnUrl, וניתוק אוטומטי מוסיף timeout —
   רק הנתיב הזה, היחיד שקורה תוך כדי עבודה, לא השתמש בה. עכשיו הוא
   מוסיף expired=1 ו-returnUrl, ומסך ההתחברות מסביר.

שומר המסלול נשאר בלי סיבה במכוון: הוא נדרס גם בכניסה ראשונה למועדף,
ושם "ההתחברות פגה" היה שקר.

נוסף spec ל-extract-error-message שמכסה את status 0 ואת שאר הצורות.
@vercel

vercel Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
talmidon Ready Ready Preview Sep 18, 2026 7:36am UTC

@yt314
yt314 merged commit e4d9a94 into main Sep 18, 2026
7 checks passed
@yt314 yt314 changed the title לומר מה נכשל: אין חיבור לרשת, והפעלה שפגה באמצע עבודה Say what failed: no network, and a session that expired mid-work Sep 18, 2026

This branch was successfully deployed

1 active deployment
Preview — ced270b0 Deployed Sep 18, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant