8000 Fixing function forwardToMsLink(), issue id: #21 by The-Lennzer · Pull Request #116 · eicrud/eicrud · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fixing function forwardToMsLink(), issue id: #21 #116

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

The-Lennzer
Copy link
@The-Lennzer The-Lennzer commented Dec 12, 2024

Implemented exponential backoff in the forwardToMsLink method to handle network-related errors.

  • Retries are attempted up to 2 times for network errors using exponential delays.
  • Added delay calculation based on an exponential backoff strategy.
  • Improved error handling to distinguish between network and non-network errors.
  • Logs retry attempts for better debugging.

BREAKING CHANGE: The method now enforces specific retry logic, and errors are thrown differently depending on the error type. Ensure that isNetworkError is properly defined when using this update.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • [x ] Other... Please describe:
    enhancement, microservice

What is the current behavior?

Throws error at first error encounter of the function.

Issue Number: #21

What is the new behavior?

Instead of immediately throwing error, If the error is network related retry twice with exponential backoff and check if it works or else then throw the error. If the error isn't network related then throw error immediately.

Does this PR introduce a breaking change?

  • [ x] Yes
  • No

The method now enforces specific retry logic, and errors are thrown differently depending on the error type. Ensure that isNetworkError(e) is properly defined when using this update.

Other information

…retries

Implemented exponential backoff in the `forwardToMsLink` method to handle network-related errors.
- Retries are attempted up to 2 times for network errors using exponential delays.
- Added delay calculation based on an exponential backoff strategy.
- Improved error handling to distinguish between network and non-network errors.
- Logs retry attempts for better debugging.

BREAKING CHANGE: The method now enforces specific retry logic, and errors are thrown differently
depending on the error type. Ensure that `isNetworkError` is properly defined when using this update.
message: error.message,
},
error.statusCode,
);
Copy link
Member

Choose a reason for hiding this comment

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

You can do throw e here for better visibility.

Additionally, to avoid recursive retries, a non-network error should be thrown in case of attempt > retries. A bad request or a special code could do.

To clarify: we don't want ms-A to retry 3 times, then throw a network error, for ms-B to retry calling ms-A 3 times (and so on).

Copy link
Member
@acrosett acrosett Dec 14, 2024

Choose a reason for hiding this comment

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

Also is-network-error doesn't seems to work with axios.

const errorMessages = new Set([
	'network error', // Chrome
	'Failed to fetch', // Chrome
	'NetworkError when attempting to fetch resource.', // Firefox
	'The Internet connection appears to be offline.', // Safari 16
	'Load failed', // Safari 17+
	'Network request failed', // `cross-fetch`
	'fetch failed', // Undici (Node.js)
	'terminated', // Undici (Node.js)
]);

My best bet would be to check the Axios docs: axios/axios#2986

https://github.com/axios/axios?tab=readme-ov-file#error-types

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
0