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

Add null check for readyState in InterceptAjaxRequestJS #2198

Conversation

furkankurt
Copy link

Add null check for readyState in InterceptAjaxRequestJS to skip events that are not done.

Connection with issue(s)

Resolve issue #2197

Connected to #404

Testing and Review Notes

To fix that issue, I've referenced this URL.

Screenshots or Videos

To Do

  • double check the original issue to confirm it is fully satisfied
  • add testing notes and screenshots in PR description to help guide reviewers
  • request the "UX" team perform a design review (if/when applicable)

@furkankurt furkankurt changed the title chore: Add null check for readyState in InterceptAjaxRequestJS Add null check for readyState in InterceptAjaxRequestJS Jun 24, 2024
@bjoernpy
Copy link

Any idea when this could be released?

@pichillilorenzo
Copy link
Owner

pichillilorenzo commented Dec 1, 2024

I was checking about this issue, but the error here is not related to some missing null checks about the current implementation, but is seems to caused by the async nature of the onAjaxReadyStateChange implementation, as if the ajax interceptor is implemented on Flutter side, the wrapper on the JavaScript side will call the XHR methods inside a Promise. In this case, it seems socket.io wants to have the onreadystatechange XHR method to be called in a sync way otherwise it will clean up its resources before the completion of that method as it expects to be, probably, called in a sync way.

What I could do is to have at least another setting/flag to disable the onAjaxReadyStateChange JavaScript wrapper handler on Flutter side, in order to disable that behaviour.

In any other case, you will probably need to implement your own custom Ajax wrapper using for example UserScript on Flutter side if there are any use edge use cases.

In general, we don't have currently a WebView native API to intercept this kind of request (maybe the shouldInterceptRequest event, that is available only on Android and Windows).

However, thanks for the support, I'm going to work on a new flag to enable/disable the onAjaxReadyStateChange where needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants