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

'abort' event not fired in qx.io.request.Xhr #9546

Open
chrisch-hh opened this issue Jul 17, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@chrisch-hh
Copy link

commented Jul 17, 2018

Don't know if it is a bug or my fault, but it seems that the abort event in qx.io.request.Xhr isn't fired correctly.

I have a tree and when the user selects a node, a request is send to fetch some additional data from a server. If the user selects another node and the request hasn't finished yet, it is canceled/aborted. I want to detect the abort of the request, but the abort event isn't fired as expected.

If I set my own function to the native XMLHttpRequest's onabort function, it is called on the abort of the request and I use this as a workaround at the moment. The problem might be that qx.bom.request.Xhr doesn't capture/handle the abort of the request correctly.

I looked into the source code of qx.bom.request.Xhr and tried to understand how the abort event is triggered. In the __initNativeXhr method there is:

// Track native abort, when supported
if (this.__nativeXhr.onabort) {
 this.__nativeXhr.onabort = this.__onNativeAbortBound;
}

this.__nativeXhr.onabort seems to be always null during the construction phase, so the __onNativeAbort function is never bound to the XMLHttpRequest's onabort function.

In the __readyStateChangeDone function, the abort event is emitted. This function is called when the request's readyState reaches qx.bom.request.Xhr.DONE. But in the case of an abort, the readyState never reaches DONE (in my use case), it remains on OPENED. So the __readyStateChangeDone function never gets called and the abort is not emitted.

Would be great if someone with more expertise could have a look on that.

Desktop (please complete the following information):

  • OS: [Windows 10, Apache 2.4]
  • Browser [Chrome 67, Firefox 61]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.