Fork me on GitHub

@viebel - one thing i’ve run into while messing around with klipse snippets is that it’s easy to completely murder a browser tab if, while editing a snippet’s code, you accidentally make it infinite loop


have you run into this before / do you think it’s possible to fix?


signing off for the night (utc-7 🙂 ), later!

Yehonathan Sharvit03:10:37

will test it later

Yehonathan Sharvit03:10:52

I’m aware of the infinite loop issue

Yehonathan Sharvit03:10:20

1. I was expecting the browser to detect it and stop the script

Yehonathan Sharvit03:10:55

2. I mitigated it by limiting the print-length of the ouptut to 1000 (configurable) so that (range) is not crashing

Yehonathan Sharvit03:10:32

3. Someone tried to solve it by wrapping all the recur statements after macro expansion. It looks interesting. It’s here: But it has some limitation:

Yehonathan Sharvit03:10:45

4. Do you have any ideas of your own?

Yehonathan Sharvit06:10:20

@jrheard I’ve merged your code and deployed it - KLIPSE version 4.4.0

Yehonathan Sharvit06:10:41

Now, I’m waiting for your blog past with the canvas stuff


nice, thanks!


i was thinking a timeout like figwheel’s repl’s might be a good solution


with a shorter timeout, like 2 seconds max instead of figwheel’s 8


haven’t looked into feasibility


will read cljs-soup in the morning, looks like it also does timeouts


expect the post early next week 😄


it’s not very complicated but i need to finish setting up my blog / etc


ok sleeptime


dang, i guess it just plain isn’t possible to kill a running function in js

jrheard16:10:39 suggests webworkers, but you can’t touch the DOM from those, and i like being able to touch the DOM in klipse


so, i’m out of ideas 🙂


i came up with a hacky idea


i’m not sure if i like it


but if it’s possible to run cljs code in the context of web workers - and i haven’t checked to see if it is - you could use them as a sort of canary


so at snippet evaluation time, each klipse snippet could spin up a web worker, let it execute for up to two seconds, and if it hasn’t executed by then you know the snippet’s code will time out, so you can kill the web worker and not execute the snippet’s code in the main js thread, and show an error message in the output codemirror window


and if the web worker executes successfully within two seconds (i don’t know anything about web workers but i’m guessing that there’s a way to be notified if the worker completes much earlier, eg after only 5ms or something), you can be relatively sure that the code is safe to run, and so then the snippet goes ahead and runs its cljs code in the context of the main js thread


the main obvious badness of this “solution” is that every snippet ends up being run twice per evaluation


and so if it has side effects, that’s bad; and if the code it contains is very slow, then it will be twice as slow as it would have been otherwise


on the other hand, again i don’t know anything about web workers but i’ve heard that they can’t manipulate the DOM, so that’s a whole category of side effect that we don’t have to worry about duplicating


anyway this idea is probably bad, but i figured i’d mention it in case it can serve as a jumping-off point for better solutions


does klipse_plugin.min.js not work for clojure? i notice that it’s not listed in the clojure example of , and i’ve had some trouble getting it to work for me


gonna try again


i get this error:

DOMException: Failed to execute 'querySelectorAll' on 'Document': The provided selector is empty.
    at Ay ()
    at By ()


hm, right - is this because bootstrapped cljs isn’t compatible with advanced compilation?

jrheard18:10:54 mentions being able to get up to :optimizations :simple


the regular plugin build compiles fine if i switch it from :whitespace to :simple - would that be a good change to make?


i see 8.1MB with the :whitespace build and 6.6MB with the :simple build


(i know you’re in a different timezone and it’s the weekend, don’t worry, i’m not expecting immediate responses to any of these messages - just writing them down so i don’t forget these things 🙂 )


it looks like the gzipped sizes are 1MB with :whitespace, 0.775MB with :simple


so maybe it’s not a huge deal, that’s not an extremely drastic difference, just figured i’d check to see if there’s a good reason not to use :simple for the plugin build


also, FYI, the twitter links at the bottom of seem to point to the wrong place


ok, here’s the post (in my blog staging area, please don’t share this via social media / etc yet, it won’t be living here long-term): . will prob publish it on monday morning