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

inputElement triggers hang with continuous xhr requests #460

Closed
maralorn opened this issue Jun 23, 2019 · 10 comments
Closed

inputElement triggers hang with continuous xhr requests #460

maralorn opened this issue Jun 23, 2019 · 10 comments
Labels

Comments

@maralorn
Copy link
Contributor

I have a freshly created project with ob init.

I changed the frontend variable in frontend/src/Frontend.hs to the following.

frontend :: Frontend (R FrontendRoute)
frontend =
  Frontend
    { _frontend_head = el "title" $ text "My Obelisk Example"
    , _frontend_body = el "div" $ void $ inputElement def
    }

No I run ob run and go to http://localhost:8000. When I click into the the inputElement my firefox runs wild with repeating requests like this:

Request URL:http://127.0.0.1:8000/jsaddle/sync/-3886772229270879785
Request method:POST
Remote address:127.0.0.1:8000
Status code: 200

Payload: {"tag":"BatchResults","contents":[43,{"tag":"Success","contents":[[],[]]}]}
Response Payload: [[{"Left":{"tag":"FreeRefs","contents":"ThreadId 18582"}}],false,43]

I would expect nothing to happen. Any insights into what is going on here would be highly appreciated.

@cgibbard
Copy link
Contributor

Which browser and platform? This jsaddle behaviour seems to happen for at least some people (if not everyone) on Firefox. I'm not entirely certain what causes it, but it only seems to happen with ob run and doesn't happen with the ghcjs frontend. Personally, I just use Chrome for ob run, even though I typically use Firefox for most things. It would be nice to sort out why this is happening.

@tshinohara
Copy link

tshinohara commented Jun 24, 2019

My understanding is that this behaviour is expected since ob run uses jsaddle-warp to run most of code on ghc side, and communicates with the browser for dom effects.
Though I haven't look into the code so I not sure if its jsaddle-warp or something else.

@cgibbard
Copy link
Contributor

cgibbard commented Jun 24, 2019

It certainly should be communicating with jsaddle, perhaps even quite a bit, depending on the user input you're providing. It should not be unresponsive and thrashing.
Using ob run, your frontend is running in ghci as native code / interpreted bytecode, not being compiled to JavaScript. It communicates a bunch with the running browser via that websocket to obtain information about what events are taking place and to obtain values only the browser could know, as well as sending commands to control what is happening in the DOM.

@tshinohara
Copy link

@cgibbard So that's how it was. Thank's for your explaination.

@maralorn
Copy link
Contributor Author

Oooh, that's interesting. All the black magic obelisk is doing would be much nicer, if I’d know about it.^^

I’m running Firefox 67.0.4 (64-bit) on nixos-19.03.

So is there a way to use ob run with the ghcjs version?

@tomsmalley
Copy link
Collaborator

There is no support for using ghcjs(i) with ob run. Unfortunately we are limited to using some variant of chromium for development, here is a related issue: ghcjs/jsaddle#64

@MazeChaZer
Copy link

I'm having the same issue in Firefox, it works in Chromium.

@blargg
Copy link
Contributor

blargg commented Nov 18, 2019

I think it would be good to warn about this when we tell people how to develop using ob run. I made a PR for this #554.

@danwdart
Copy link

danwdart commented Mar 5, 2021

Is this not because it's synchronous?

@madeline-os
Copy link
Collaborator

We have a note about this in the README and I am adding a section to the FAQ in #927, as it is easy to miss. Beyond that, all I can do is attempt to push effort in the direction of fixing the issue upstream.

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

No branches or pull requests