Parse-SDK-JS
Parse-SDK-JS copied to clipboard
Promise is never resolved when a server is down
New Issue Checklist
- [x] I am not disclosing a vulnerability.
- [x] I am not just asking a question.
- [x] I have searched through existing issues.
- [x] I can reproduce the issue with the latest versions of Parse Server and the Parse JS SDK.
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
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.
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.
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);
}
Sounds reasonable. Do you think you can submit a PR with a test and a fix for this?
Yep. I'll try to do it today
Hi, @mtrezza! Will you check the PR?
Sure, feel free to request a review inside the PR anytime.