-
Notifications
You must be signed in to change notification settings - Fork 0
🧹 [Code Health] Implement Secure Telemetry Fallback Mechanism #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -473,9 +473,11 @@ async function executeBatchPayload() { | |||||||||||||||||||||||||||||||||
| setTimeout(onSyncSuccess, 1500); // Simulate sync delay | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||||||
| console.error("Critical Sync Failure:", error); | ||||||||||||||||||||||||||||||||||
| DOM.syncStatus.innerHTML = `<span style="color:#ff453a">⚠️ Sync Failed. Error: ${error.code || 'Network'}</span>`; | ||||||||||||||||||||||||||||||||||
| // Potential fallback: Save to localStorage for later recovery | ||||||||||||||||||||||||||||||||||
| // Fallback: Save to localStorage for later recovery | ||||||||||||||||||||||||||||||||||
| localStorage.setItem(`telemetry_backup_${STATE.pid}`, JSON.stringify(STATE.results)); | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+476
to
+477
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| DOM.syncStatus.style.color = "#ff453a"; | ||||||||||||||||||||||||||||||||||
| DOM.syncStatus.textContent = "Diagnostic Complete. A network timeout occurred. You may safely close this tab."; | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+479
to
+480
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The color string
Comment on lines
+476
to
+480
|
||||||||||||||||||||||||||||||||||
| // Fallback: Save to localStorage for later recovery | |
| localStorage.setItem(`telemetry_backup_${STATE.pid}`, JSON.stringify(STATE.results)); | |
| DOM.syncStatus.style.color = "#ff453a"; | |
| DOM.syncStatus.textContent = "Diagnostic Complete. A network timeout occurred. You may safely close this tab."; | |
| // Fallback: Attempt to save to localStorage for later recovery | |
| let message = "Diagnostic Complete. A network timeout occurred. You may safely close this tab."; | |
| try { | |
| localStorage.setItem(`telemetry_backup_${STATE.pid}`, JSON.stringify(STATE.results)); | |
| } catch (storageError) { | |
| console.warn("Unable to persist telemetry backup to localStorage:", storageError); | |
| message = "Diagnostic Complete. A network timeout occurred and local backup could not be saved. You may safely close this tab."; | |
| } | |
| DOM.syncStatus.style.color = "#ff453a"; | |
| DOM.syncStatus.textContent = message; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
localStorage.setItemcall can throw an exception if storage is full or disabled (e.g., in private browsing mode). This would interrupt thecatchblock and prevent the user from seeing the final status message. To make the error handling more robust, this operation should be wrapped in its owntry...catchblock to ensure the UI is always updated, even if the data backup fails.