qzind / qz-print

Archive for legacy qz-print versions (1.8, 1.9). See https://github.com/qzind/tray for modern versions.
Other
141 stars 101 forks source link

async:false is deprecated on main thread #49

Closed tresf closed 8 years ago

tresf commented 9 years ago

Since signRequest() requires async:false, we need to use it to prevent race conditions, however Chrome displays a deprecation warning.

@bberenz do we have the ability to workaround this to prevent breaking down the road or is this a ticking time bomb?

tresf commented 9 years ago

So I believe the async:false warning to be generated by jQuery, not the web browser. This is slightly better, since we can force a certain version of jQuery for now, but that slows down scalability.

What techniques can we use to survive the removal of async:false ?

akberenz commented 9 years ago

Reading through the jquery ticket that lead to deprecation on async: false, I do not think we have to worry. The deprecation only applies to a specific use case of ajax calls (use with deferred/promises), and remains valid with the use of callback functions (ie success: function() {...}). There is also mention in the ticket that if async: false is removed from ajax, that an alternative method of synchronous calls will be provided.

tresf commented 9 years ago

Could we shim in a setTimout 0 in there somewhere to take it off of the main thread?

akberenz commented 9 years ago

We can, but I don't know if that will reintroduce the race condition in the signing, since it will make the signRequest() function return immediately again.

tresf commented 9 years ago

Yeah, good point...

I assume we'll have room to improve the API in 2.0 and we can discuss this. So from what I read, jQuery requires async: false for its own API, right?

akberenz commented 9 years ago

Yes, if you are expecting to get a javascript promise back, then it has to be an asynchronous call. There would have been too much overhead to have allowed them to make synchronous calls.

akberenz commented 8 years ago

I'm going to close this, because 2.0 uses promises around the security calls now, removing this concern.

demopix commented 5 years ago

I gave this answer somewhere else https://stackoverflow.com/questions/48322574/asyncfalse-deprecated-whats-the-simple-way-forward/53637807#53637807

xewl commented 5 years ago

I gave this answer somewhere else https://stackoverflow.com/questions/48322574/asyncfalse-deprecated-whats-the-simple-way-forward/53637807#53637807

demopix pls

tresf commented 5 years ago

Previous versions of this plugin did everything on the main thread. This was a design side effect of mimicking LiveConnect calls. Newer versions have moved asynchronous calls to leverage newer JavaScript techniques. (Promise, await). These newer techniques have been adopted by all major browsers as well as JavaScript frameworks.