Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Error in Haskell code seems to leave JS promise hanging #579

Closed
pimlu opened this issue Apr 15, 2020 · 6 comments
Closed

Error in Haskell code seems to leave JS promise hanging #579

pimlu opened this issue Apr 15, 2020 · 6 comments

Comments

@pimlu
Copy link

pimlu commented Apr 15, 2020

Hey, I'm back with another go at porting my FRACTRAN thing to Asterius.

Describe the bug
An uncaught error triggered in Haskell code doesn't trigger the Promise.catch() callback (simple usage seen here)

To Reproduce
Call FFI foreign export function from JS with input that triggers an uncaught error

Expected behavior
Promise.catch() callback is called with a failure (instead, neither try nor catch callback is called)

Environment

  • OS name + version: Ubuntu 18.04.4 LTS (but I'm using docker)
  • GHC version: 8.8.3
  • Version of Asterius: Latest from docker

Additional context
This is running in a web worker to avoid hanging the UI thread.

@TerrorJack
Copy link
Member

Thanks for reporting. I confirmed locally with a smaller case that hangs node instead of rejecting. Will look into this further.

@TerrorJack
Copy link
Member

Could you give the terrorjack/asterius:wip-580-mitigate image a try and see if the problem persists?

@pimlu
Copy link
Author

pimlu commented Apr 15, 2020

I gave it a try, valid inputs still work as expected, for invalid inputs, it triggers the catch now as expected, but the err argument passed into the callback is undefined, so I don't get the data from the error.

It logs updateThunk failed with RuntimeError: barf: when the error triggers.

@TerrorJack
Copy link
Member

Yes, that's expected, since for now the mitigation only ensures that the Promise rejection happens, but more work is needed to debug the root cause and make sure the Haskell exception is visible in the rejection value.

Let's keep this issue open for now; master branch and the images will be updated shortly.

@pimlu
Copy link
Author

pimlu commented Apr 15, 2020

Alright, that sounds good, I only have one kind of error (although it reports the state when the error happened), so I can just not report the state that triggered it for now. Switching to Asterius is still worth it imo, especially because of Haste's stack overflow bug which is common in large programs.

My one reservation is that when I call the FFI export, the webworker spends about ~40% of the time idling during the computation (I guess because of the scheduler stuff). I want Asterius to just slam the CPU at 100% inside my webworker. If it can do that, its performance will roughly match Haste. Is there a way to configure Asterius like that?

@TerrorJack
Copy link
Member

Closed by #628. Thanks again for reporting this one :)

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

No branches or pull requests

2 participants