Skip to content
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

fix: Fix incorrect Promise structure in customFetch timeout logic #1652

Merged
merged 2 commits into from
Dec 17, 2024

Conversation

defitricks
Copy link
Contributor

This update resolves an issue in the customFetch function where the second promise in the Promise.race block was constructed incorrectly. Previously, it used new Promise(() => ...), which omitted the required resolve and reject arguments for the executor function. This omission could lead to runtime errors as the promise neither resolves nor rejects upon timeout.

The corrected implementation ensures proper handling by rejecting the promise when the timeout occurs:

new Promise((_, reject) =>
  setTimeout(() => {
    controller.abort();
    reject(new Error('API request timeout'));
  }, timeout)
)

This change improves reliability and ensures errors are properly propagated during timeout scenarios.

@ChaituVR ChaituVR requested review from Copilot and ChaituVR December 17, 2024 13:29

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

@ChaituVR ChaituVR merged commit 36bd2d7 into snapshot-labs:master Dec 17, 2024
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