Skip to content

Fix timeout error#128

Merged
vladavoX merged 4 commits intomasterfrom
fix-timeout-error
Feb 25, 2026
Merged

Fix timeout error#128
vladavoX merged 4 commits intomasterfrom
fix-timeout-error

Conversation

@vladavoX
Copy link
Contributor

  • timeout aproach is not good, we should not block the user when his connections are interupted, or it takes too long to upload.
  • check codes and then throw based on them

@vladavoX vladavoX requested a review from danixeee February 24, 2026 15:40
Copy link
Contributor

@danixeee danixeee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

Overview

This PR removes the 5-second request timeout from the axios instance and replaces the simple navigator.onLine check with a more robust isLikelyOfflineError() function that detects various network error conditions.

What's Good

  • Comprehensive error detection: The NO_INTERNET_ERROR_CODES set covers common DNS/network failure codes
  • Defense in depth: Multiple detection strategies (navigator.onLine, error codes, message parsing)
  • Clean separation: The isLikelyOfflineError() helper is well-structured and easy to test

Concerns

  1. Complete removal of timeout - This is the main concern. Removing the timeout entirely means requests can hang indefinitely if:

    • The server accepts the connection but never responds
    • A corporate proxy holds the connection open
    • File uploads to a slow endpoint never complete

    Suggestion: Consider keeping a longer timeout (e.g., 30-60s for API calls) rather than removing it entirely, or use per-request timeouts for upload operations specifically.

  2. navigator availability in Node environment - This code runs in src/node/. The navigator object is a browser API and won't exist in Node.js. While the code guards against this, it's effectively dead code here.

  3. Message parsing fragility - String matching on error messages ('network error', 'getaddrinfo enotfound', etc.) is fragile—messages can change between axios versions or be localized. Consider relying primarily on error codes.

  4. Missing error codes - Consider adding:

    • ETIMEDOUT - connection timeout (especially relevant if you restore timeouts)
    • ECONNREFUSED - server not running
    • ECONNRESET - connection reset by peer

Recommendations

  1. Don't remove timeout entirely—use a longer default (30-60s) or remove only for upload operations
  2. Add ETIMEDOUT, ECONNREFUSED, and ECONNRESET to NO_INTERNET_ERROR_CODES
  3. Add unit tests for isLikelyOfflineError() with various error scenarios

@vladavoX vladavoX requested a review from danixeee February 25, 2026 08:08
@vladavoX vladavoX merged commit 4436ab8 into master Feb 25, 2026
3 checks passed
@vladavoX vladavoX deleted the fix-timeout-error branch February 25, 2026 08:46
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.

2 participants