-
Notifications
You must be signed in to change notification settings - Fork 144
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
XHR: Refused connection causes runtime error #334
Comments
The following code seems to work instead of the current version:
I am very new to GHCJS, so please tell me whether this is the best way to check for |
... at least in GHCJS. In jsaddle-warp, I still get the same error stangely. |
Hi @johannesgerer . Thank you very much for taking the time to file an issue! Do you think you could provide the version or hash of reflex-dom that you were using? I am unable to reproduce the issue, as the resulting event from frontend = Frontend
{ _frontend_head = el "title" $ text "Obelisk Minimal Example"
, _frontend_body = void $ prerender (pure ()) $ do
ev <- button "press me"
let
url = "http://localhost:800/"
reqConfig = def
{
_xhrRequestConfig_responseType = (Just XhrResponseType_ArrayBuffer)
, _xhrRequestConfig_headers = "Access-Control-Allow-Origin" =: "*"
, _xhrRequestConfig_responseHeaders = AllHeaders
}
reqEv = xhrRequest "GET" url reqConfig <$ ev
-- print a msg to the terminal each time the response event from performRequestAsync fires
resEv <- fmap (traceEventWith (const "Response Event has fired")) $ performRequestAsync reqEv
dTxt <- holdDyn "init" $ ffor resEv $ \res ->
case (_xhrResponse_response res) of
Nothing -> "empty body"
Just body ->
case body of
XhrResponseBody_ArrayBuffer arr -> (T.pack $ show $ _xhrResponse_statusText res) <> " array"
_ -> "other body"
dynText dTxt
pure ()
}
|
I'm able to reproduce this issue with jsaddle-warp and the current version of reflex and reflex-dom, so I think this should be reopened. edit: unfortunate wording error |
Not sure if that helps, but here is where the error originates: https://github.com/ghcjs/jsaddle/blob/d569be43f92b9b8c01dc3ee4c41401ab406a2076/jsaddle/src/Language/Javascript/JSaddle/Run/Files.hs#L431 |
This could be a CORS issue. See https://stackoverflow.com/questions/8456538/origin-null-is-not-allowed-by-access-control-allow-origin and https://stackoverflow.com/a/37690646/1013628 for some suggestions on how to workaround the issue. In my specific case, I could get a more informative error message by setting
I fixed it by following the answer here https://stackoverflow.com/a/42150084/1013628 |
Thanks for your work on this great package!
I encountered the following problem when using the ArrayBuffer result type in the performRequestsAsync call.
If I try to query a non existing host/port, the whole app crashes when I try to access the _xhrResponse_response and I see the following console log:
There seems to be something wrong with the way Reflex.Dom.Xhr.Foreign parses the body into an ArrayBuffer.
This happens in Chrome and Firefox with both GHCJS and jsaddle-warp.
The text was updated successfully, but these errors were encountered: