Hi! I am new to Calva and VS Code. Calva (I assume) keeps crashing on me, with
Extension host terminated unexpectedly.
Admittedly, I am doing bad stuff - I have a JS project and I just created a .cljs file in there, without a ns declaration and thus code that would not compile (just writing something for a talk). Here is the file:
;; fulcro-talk-fulcro.cljs
;; ################################################# FRONTEND
;; FRONTEND - all of it: deals.cljs
(def deal (fcomp/factory Deal)) ;; Deal not shown
(defsc HotDeals [this {:keys [deals] :as props}]
{:query [{:deals (fcomp/get-query Deal)} [ffetch/marker-table :deals]]
:componentDidMount (fn [this] (ffetch/load!
this :deals Deal
{:marker :deals}))}
(let [marker (get props [ffetch/marker-table :deals])]
(cond
(ffetch/failed? marker) (p "Something went wrong...")
(ffetch/loading? marker) (p "Loading...")
:else (ul (map deal deals)))))
;; ################################################# BACKEND
;; BACKEND: graph-api.clj
(pc/defresolver hot-deals [env _]
{::pc/input #{}
::pc/output [{:deals [:deal/id :deal/title ...]}]}
{:deals (hot-deals env)})
;; In config:
... (pc/connect-plugin {::pc/register [hot-deals ...]}) ...
;; BACKEND: webshop.clj
(defn hot-deals [env] ...)
In the Dev Tools Console I do not see much useful:
WARN UNRESPONSIVE extension host, 'borkdude.clj-kondo' took 100% of 18859.375ms
[Extension Host] (node:7699) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(),...
Extension host terminated unexpectedly. Code: null Signal: SIGBUS
I'd be happy to help troubleshoot this.
PS: VS Code has opened an issue for the slow clj-kondo start: https://github.com/borkdude/clj-kondo.lsp/issues/8
Version: 1.46.0
Commit: a5d1cc28bb5da32ec67e86cc50f84c67cc690321
Date: 2020-06-10T08:59:06.977Z (1 day ago)
Electron: 7.3.1
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 19.5.0
@holyjak I for one can't reproduce it given the file you posted:

The extensions start only the first time you open a project and then keep running the entire time. So for testing different you might have to close and re-open the editor.
java process in the Activity Manager with 100% CPU?
$ clj-kondo --lint ...? Do you also see a spike in CPU for a longer time?FWIW I just released clj-kondo 2020.06.12 so we can have an equal comparison between the LSP plugin and the binary.
This might be happening in Calva. I get this message pasting that code into a new editor window:
WARN UNRESPONSIVE extension host, 'betterthantomorrow.calva' took 97% of 5142.859ms
Indeed, trying this without clj-kondo involved at all still produces the problem.
I have not yet understood why this crash happens, but I now know where.
This regex:
toplevel.terminal(/(#[^\(\)\[\]\{\}'"_@~\s,]+[\s,]*)*((?<=(^|[\(\)\[\]\{\}\s,]))['`~#@?^]\s*)*['`~#@?^]*[\(\[\{"]/, (l, m) => ({ type: "open" }))
Runs amok, on this input:
;; ################################################# FRONTEND
I'm sorry about the inconvenience, @holyjak. It is quite strange this problem hasn't been found until now.
Here's a repro of the underlying problem:
const t = '#################################################';
const p = /(#[^\(\)\[\]\{\}'"_@~\s,]+[\s,]*)*((?<=(^|[\(\)\[\]\{\}\s,]))['`~#@?^]\s*)*['`~#@?^]*[\(\[\{"]/;
const rx = new RegExp(p, 'g');
x = rx.exec(t);
This never completes. (Well, I don't know about ”never”, but whatever, VS Code loses its patience anyway.)
Running this with regex101 tester - https://regex101.com/r/KBupNZ/1 - I get different results between:
Further, it seems to be a problem with exponential growth of the time the matching takes. So in rexex101 15 # works fine also in Chrome, but 20-21 starts to take time. And from there takes exponentially more time for each added character.
Not sure what the next step should be, but I've pushed a branch where the problem is exposed in (disabled) tests: https://github.com/BetterThanTomorrow/calva/tree/fix/667-crash-on-comment-w-hashes
Any ideas why VSCode reported clj-kondo as the problematic plugin instead of Calva?
Great jobs, folks! Thank you, I will use a different section separator nex
time, until Chrome fixes its behavior. And don't worry, it was no big deal,
I wasn't really programming :-)
On Sat, 13 Jun 2020, 10:33 Michiel Borkent, notifications@github.com
wrote:
Any ideas why VSCode reported clj-kondo as the problematic plugin instead
of Calva?—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/BetterThanTomorrow/calva/issues/667#issuecomment-643591477,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAEYSPRO24JFN3RLJKXOMTLRWM2UZANCNFSM4N4BVA6A
.
And, I just confirmed my suspicion that the problem is there inside strings as well. Which is bad, because in a forum where I asked for help, there were some ideas floating that could have been used to work around this if it was only in comments lines.
@borkdude , that was really strange. The only thing similar to an idea I have about it is that Calva starts parsing the file as the very first thing that happens when the file is opened. And if it is opened when VS Code opens the project, among the very first things that happen is this failed parsing. Maybe VS Code starts the clj-kondo extension first, then Calva hangs the thread and the start of clj-kondo times out?
The smallest repro of the regex problem I can produce:
(#[^a]+\s*)*b
@PEZ Just FYI, this regex you mentioned is the one I recently added a ' to when I fixed the var quote highlighting issue.
toplevel.terminal(/(#[^\(\)\[\]\{\}'"_@~\s,]+[\s,]*)*((?<=(^|[\(\)\[\]\{\}\s,]))['`~#@?^]\s*)*['`~#@?^]*[\(\[\{"]/, (l, m) => ({ type: "open" })
This may have been an issue before that too, but wanted to mention just in case it effects anything - though I don't see how it would.
It didn't. 😀
This is from when I added reader tags to the opening brackets. But even if I revert that other rules run amok, so it will be some work fixing this.
Soon fixed, @holyjak . Thanks for reporting!
Awesome, thanks!
On Sun, 14 Jun 2020, 14:10 Peter Strömberg, notifications@github.com
wrote:
Soon fixed, @holyjak https://github.com/holyjak . Thanks for reporting!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/BetterThanTomorrow/calva/issues/667#issuecomment-643758071,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAEYSPWZQJKGQTOCXSRVNBLRWS43JANCNFSM4N4BVA6A
.