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

Promise is never resolved when a server is down #1417

Open
4 tasks done
igor-lemon opened this issue Sep 29, 2021 · 7 comments
Open
4 tasks done

Promise is never resolved when a server is down #1417

igor-lemon opened this issue Sep 29, 2021 · 7 comments
Labels
bounty:$5 Bounty applies for fixing this issue (Parse Bounty Program) type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@igor-lemon
Copy link

igor-lemon commented Sep 29, 2021

New Issue Checklist

Issue Description

The Promise from RESTController will never resolved when a server is down.

Steps to reproduce

Set some wrong URL as parse server url , parse.serverURL = 'https://some-wrong-site.com'
Call

 const parseConfig = await Parse.Config.get()

Actual Outcome

The promise will never resolve.

Expected Outcome

The promise should be rejected.

Environment

Client

  • Parse JS SDK version: 3.3.1
@parse-github-assistant
Copy link

parse-github-assistant bot commented Sep 29, 2021

Thanks for opening this issue!

  • 🚀 You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.

@igor-lemon igor-lemon changed the title Promise is never resolved when server is down Promise is never resolved when a server is down Sep 29, 2021
@mtrezza mtrezza added the type:bug Impaired feature or lacking behavior that is likely assumed label Sep 29, 2021
@mtrezza
Copy link
Member

mtrezza commented Sep 29, 2021

What would be the expectation? To reject the promise after a timeout? I would assume the JS SDK already has a retry/timeout mechanism in place in case of bad network connection.

@igor-lemon
Copy link
Author

Yep, I think we should make a few retries (if I remember 5 by default) but after the promise should be rejected.
We have infinity waiting at the moment.

I think it related with if (xhr.readyState !== 4 || handled || xhr._aborted) condition.
We have xhr.readyState === 1 and just exit from the handler and after we don't make any repeat attempts.
I solved it at the local build when reject the promise at RESTControlle.js

 if (xhr.readyState !== 4 || handled || xhr._aborted) {
   promise.reject(xhr);
 }

@mtrezza
Copy link
Member

mtrezza commented Sep 29, 2021

Sounds reasonable. Do you think you can submit a PR with a test and a fix for this?

@igor-lemon
Copy link
Author

Yep. I'll try to do it today

@igor-lemon
Copy link
Author

Hi, @mtrezza!
Will you check the PR?

@mtrezza
Copy link
Member

mtrezza commented Sep 30, 2021

Sure, feel free to request a review inside the PR anytime.

@mtrezza mtrezza added severity:medium bounty:$5 Bounty applies for fixing this issue (Parse Bounty Program) labels Oct 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty:$5 Bounty applies for fixing this issue (Parse Bounty Program) type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

No branches or pull requests

2 participants