canjs / can-ajax

jQuery-inspired AJAX request library.
https://canjs.com/doc/can-ajax.html
MIT License
5 stars 7 forks source link

Chrome sometimes does not default async parameter to true #51

Closed RyanMilligan closed 5 years ago

RyanMilligan commented 5 years ago

The exact circumstances are unknown, but sometimes, when running in Chrome, calling xhr.open() without passing an async value results in a synchronous network call. This can be solved by explicitly passing true.

phillipskevin commented 5 years ago

Gitter conversation: https://gitter.im/canjs/canjs?at=5c01a23e9aec405095a8bea1

phillipskevin commented 5 years ago

@RyanMilligan confirmed can-fixture isn't being loaded: https://gitter.im/canjs/canjs?at=5c01bb5043c68b3727ddbaf7

cherifGsoul commented 5 years ago

@phillipskevin @RyanMilligan what should fixed for this issue and what is the expected behavior?

phillipskevin commented 5 years ago

xhr.open that we call here: https://github.com/canjs/can-ajax/blob/d5241b027ac2b44ec83e7014c89db2eccda72af6/can-ajax.js#L217

Is supposed to default the async parameter to true.

Which means that the promise should be returned here before the response to send is received: https://github.com/canjs/can-ajax/blob/d5241b027ac2b44ec83e7014c89db2eccda72af6/can-ajax.js#L257-L258

@RyanMilligan found that this is not always happening, so we should try to verify this and then explicitly pass true as the async parameter if required.

cherifGsoul commented 5 years ago

@phillipskevin Maybe we should async params to the options list if is not set it will be true.

phillipskevin commented 5 years ago

I don't think it really makes sense to have the option to pass async: false, since ajax will still return a function.

I think we just add a test that checks that true is passed to open and pass it explicitly.