fix/wrong-message-offline #222

Merged
hodlbod merged 2 commits from DeveshSingh/flotilla:fix/wrong-message-offline into dev 2026-04-17 18:24:56 +00:00
Contributor

Title

Fix: Differentiate network errors from auth errors in SpaceInvite.svelte

Description

The Problem
When a user attempted to create a space invite while offline or experiencing network connectivity issues, the SpaceInvite.svelte modal would incorrectly display the message: "Oops! It looks like you're not a member of this relay."

Because @welshman/net's request() resolves silently on network failure rather than throwing an error, the component's catch block never executed. Instead, the deriveRelayAuthError thunk would fail in the background, surfacing a generic network failure string (e.g. "Failed to publish to any relays" or "Timeout"). The template previously treated any truthy $authError string as an authentication rejection, leading to misleading UI feedback.

The Solution
Following PR feedback to avoid relying solely on the heuristic navigator.onLine, this PR updates the component to classify errors directly based on the request's failure string:

  1. Explicit Error Classification: Created isExplicitAuthError and isGenericError derived states. We now parse the $authError string—if it contains keywords indicating a network or signing failure (failed, timeout, network), it is caught and treated as a generic connectivity issue.
  2. Accurate UI Messaging:
    • True auth rejections (restricted: ..., forbidden: ...) now correctly display: "Oops! It looks like you're not a member of this relay."
    • Network timeouts, offline states, and captive portal drops fall back to the generic error: "Unable to reach the relay. Please check your connection and try again."
  3. TypeScript Fix: Fixed a Property 'name' does not exist on type '{}' TypeScript error in the catch block by implementing a proper instanceof Error type guard and standardizing checks for both "AbortError" and "TimeoutError".

Testing Performed

  • Disabled network via browser DevTools: Verified that the generic "Unable to reach relay" message is correctly displayed.
  • Successfully generated an invite on an active connection.
### Title Fix: Differentiate network errors from auth errors in SpaceInvite.svelte ### Description **The Problem** When a user attempted to create a space invite while offline or experiencing network connectivity issues, the `SpaceInvite.svelte` modal would incorrectly display the message: *"Oops! It looks like you're not a member of this relay."* Because `@welshman/net`'s `request()` resolves silently on network failure rather than throwing an error, the component's `catch` block never executed. Instead, the `deriveRelayAuthError` thunk would fail in the background, surfacing a generic network failure string (e.g. `"Failed to publish to any relays"` or `"Timeout"`). The template previously treated *any* truthy `$authError` string as an authentication rejection, leading to misleading UI feedback. **The Solution** Following PR feedback to avoid relying solely on the heuristic `navigator.onLine`, this PR updates the component to classify errors directly based on the request's failure string: 1. **Explicit Error Classification:** Created `isExplicitAuthError` and `isGenericError` derived states. We now parse the `$authError` string—if it contains keywords indicating a network or signing failure (`failed`, `timeout`, `network`), it is caught and treated as a generic connectivity issue. 2. **Accurate UI Messaging:** - True auth rejections (`restricted: ...`, `forbidden: ...`) now correctly display: *"Oops! It looks like you're not a member of this relay."* - Network timeouts, offline states, and captive portal drops fall back to the generic error: *"Unable to reach the relay. Please check your connection and try again."* 3. **TypeScript Fix:** Fixed a `Property 'name' does not exist on type '{}'` TypeScript error in the `catch` block by implementing a proper `instanceof Error` type guard and standardizing checks for both `"AbortError"` and `"TimeoutError"`. **Testing Performed** - Disabled network via browser DevTools: Verified that the generic "Unable to reach relay" message is correctly displayed. - Successfully generated an invite on an active connection.
hodlbod added 2 commits 2026-04-17 18:24:48 +00:00
hodlbod force-pushed fix/wrong-message-offline from a4b35d9774 to 79a4e22cd4 2026-04-17 18:24:48 +00:00 Compare
hodlbod merged commit 3c66dfd83c into dev 2026-04-17 18:24:56 +00:00
hodlbod deleted branch fix/wrong-message-offline 2026-04-17 18:24:56 +00:00
Sign in to join this conversation.