Repository navigation
Say what failed: no network, and a session that expired mid-work - #47
Merged
Merged
Conversation
שני מקרים שבהם המסך ידע מה קרה ולא אמר:
1. כשאין רשת, Angular מחזיר status 0 בלי גוף תשובה, וההודעה שהוצגה
הייתה הנוסח הכללי ("העדכון נכשל"). זה משאיר פתוחה את השאלה אם
השינוי נשמר. עכשיו: "אין חיבור לשרת. בדקי את החיבור לאינטרנט ונסי
שוב." — גם מסביר מה קרה וגם אומר מה לעשות.
2. כשההפעלה פגה באמצע עבודה, רענון הטוקן נכשל והמשתמשת נזרקה למסך
התחברות ריק, בלי סיבה ובלי חזרה למקום שבו הייתה. היכולת כבר קיימת
בקוד — שומר המסלול מוסיף returnUrl, וניתוק אוטומטי מוסיף timeout —
רק הנתיב הזה, היחיד שקורה תוך כדי עבודה, לא השתמש בה. עכשיו הוא
מוסיף expired=1 ו-returnUrl, ומסך ההתחברות מסביר.
שומר המסלול נשאר בלי סיבה במכוון: הוא נדרס גם בכניסה ראשונה למועדף,
ושם "ההתחברות פגה" היה שקר.
נוסף spec ל-extract-error-message שמכסה את status 0 ואת שאר הצורות.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
"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 0with no response body, and that can be said outright: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:
A blank login form, no reason, no way back. The interesting part: the capability already existed in the code.
auth.guard.tsaddsreturnUrl,idle-logout.service.tsaddstimeout=1and the login screen explains "you were logged out for inactivity". Onlyauth.interceptor.ts— the one path of the three that fires while she is working — used neither.After the fix:
A deliberate decision: the route guard stays silent
auth.guard.tsdoes not getexpired=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 forextract-error-messagecoveringstatus 0, a 409 carrying a real message (so it is not mistaken for a lost connection), a controllermessage, anerrorsarray, a ProblemDetailserrorsdictionary, and the fallback. (app.spec.tsfails on main too — unrelated.)page.routeto drop the network and to return 401.Demo data untouched — 4 teachers, 3 students.