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

sample-app-jsaddle doesn't work under Firefox #597

Closed
niteria opened this issue Jun 18, 2020 · 1 comment
Closed

sample-app-jsaddle doesn't work under Firefox #597

niteria opened this issue Jun 18, 2020 · 1 comment

Comments

@niteria
Copy link
Contributor

niteria commented Jun 18, 2020

Describe the bug
If you build the sample-app-jsaddle app and open it in Firefox the app will hang, loop sending many XHR requests and you get Error : Unexpected Duplicate. syncCallbacks=True nBatch=4 nExpected=6 on stdout.

This is not really an issue with miso, but with jsaddle. miso is triggering ghcjs/jsaddle#64

I'm opening this because I think this is easy to side-step in miso.

Additional context
The crux of the problem with jsaddle + Firefox is that Firefox (as opposed to Chrome) is strict about disallowing synchronous XHR requests.

Synchronous XHR requests are used in jsaddle to implement calls from the browser to the jsaddle backend for Haskell functions that return results.

Fortunately miso is written in a continuation-passing style, so as far as I can tell it has no need for such functions.

In fact, the only instance of using a sync function that I run into is in

delegateEvent :: JSVal -> JSVal -> JSM JSVal -> JSM ()
delegateEvent mountPoint events getVTree = do
cb' <- function $ \_ _ [continuation] -> do
res <- getVTree
_ <- call continuation global res
pure ()
delegateEvent' mountPoint events cb'
.

It's clearly not using the result, and changing from function to asyncFunction on this line

cb' <- function $ \_ _ [continuation] -> do
made the sample-app-jsaddle and my own app run successfully under jsaddle on Firefox.

niteria added a commit to niteria/miso that referenced this issue Jun 19, 2020
The github issue explains the rationale.
The gist is that sync functions don't work in jsaddle+Firefox and
miso doesn't need a sync function here, async is fine.
niteria added a commit to niteria/miso that referenced this issue Jun 19, 2020
The github issue explains the rationale.
The gist is that sync functions don't work in jsaddle+Firefox and
miso doesn't need a sync function here, async is fine.
niteria added a commit to niteria/miso that referenced this issue Jun 19, 2020
The github issue explains the rationale.
The gist is that sync functions don't work in jsaddle+Firefox and
miso doesn't need a sync function here, async is fine.
dmjio pushed a commit that referenced this issue Jun 19, 2020
The github issue explains the rationale.
The gist is that sync functions don't work in jsaddle+Firefox and
miso doesn't need a sync function here, async is fine.
@niteria
Copy link
Contributor Author

niteria commented Jun 20, 2020

Fixed by afe2536

@niteria niteria closed this as completed Jun 20, 2020
cdfa added a commit to cdfa/miso that referenced this issue Sep 17, 2021
I think this causes Firefox to spin indefinitely when using JSaddle.
Context: dmjio#597
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant