-
Notifications
You must be signed in to change notification settings - Fork 98
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
How to error if layout takes too long? #258
Comments
Hey, wondering if there is an update on this ? or perhaps a around ? |
I think that I found the problem here, it is an issue with create react app. CRA does not properly load the worker's script. The error signifies that the worker script cannot be found during runtime.
However, a proper solution would be to take advantage of webpack 5 support of web workers
|
There is currently no process on our side. Is this something we should include in our readme? |
yeah that's a good idea I think. Could save others a ton of time. |
Describe the bug
I've run into an infinite loop via eclipse/elk#993 and I'm trying to ensure my app can continue if a case like this turns up.
I initially thought I could use
Promise.race
withsetTimeout
to error:but this still froze my app when laying out - I think I misunderstood how promises work, and that
elk.layout
must be reaching the infinite loop synchronously.So then I looked more and realized, hey maybe that's what the out-of-the-box Web Worker support is for, since it seems that Web Workers are a way to run JavaScript on a separate thread. So I tried initializing elk to use a web worker (still with the above
Promise.race
implementation):but my app still freezes when laying out.
Expected behavior
Can throw a timeout error after X seconds of trying to layout.
Screenshots
ELK Version
0.9.0 (which is 0.9.1 elkjs version?)
Additional context
I can't actually tell if the worker is being used, but no console errors are being thrown, and when I'm not using the layout that reproduces the infinite loop, layout is still performed as expected. before using the above Web Worker implementation, I did try the README's
but this results in
Uncaught SyntaxError: Unexpected token '<' (at elk-worker.min.js:1:1)
. I can detail the various combinations I tried using to use a worker viaworkerUrl
if we suspect that's the problem.The text was updated successfully, but these errors were encountered: