all calva features suddenly unaccessible in the middle of editing
It happened to me 2-3 times already during previous few months, that Del/Backspace keys suddenly stopped working in the middle of editing. Restarting vs code usually fixed the problem. But I think that it didn't in one case and as a result I also ended up tryin go delete .lsp folder. Which seemed to help, but it might have been a coincidence - not sure there.
Last time it happened, I realized that actually all calva actions cannot get executed, not just the ones bound to del/backspace. Even if I create an empty .clj file and write some hello-world expression there, I'm not able to indent it, format it, expand selection, execute it.. basically no calva-related actions.
We've discussed this a bit at this thread on clojurians slack: https://clojurians.slack.com/archives/CBE668G4R/p1620139199001200?thread_ts=1619443092.252700&cid=CBE668G4R
I'm attaching a copy-paste from Developer Tools console output + the cpu file the console mentions that got logged. Hopefully it will shed some light into what went wrong :crossed_fingers:
(had to rename .cpuprofile file to .cpuprofile.txt as github didn't like .cpuprofile extension and refused to upload it)
Interesting things I see:
TypeError: e.filter is not a function- I see this in several places, coming from Calva.ERR Cannot read property 'start' of undefined: TypeError: Cannot read property 'start' of undefined- also in several places and coming from Calva, though many things have astartproperty, so I'm not immediately sure where this is from.Error in_formatIndex: Unexpected EOF. [at line 9, column 59]- from Calva, I think from the formatter.log.ts:296 ERR [line 1, col 24] Invalid token: :- Maybe not from Calva?LogService.ts:66 xterm.js: Parsing error: Object- Maybe not from Calva?Calva Formatter Error: Unclosed open-paren.-
log.ts:290 WARN UNRESPONSIVE extension host, 'betterthantomorrow.calva' took 93% of 5149.568ms, saved PROFILE here: 'file:///tmp/exthost-59fb4f.cpuprofile' Array(2) 2log.ts:290 WARN Error: Aborted onWillSaveTextDocument-event after 1750ms
Definitely seems like something is causing Calva to hog resources. Does this happen even in a new minimal project?
Unfortunately this issue appears in random fashion. So far it happened only 2-3times. This time it was a really small project: a small command-line tool, consisting of single core.clj (approx. 600 rows including many rich comments), few cognitect aws libs. Definitely a tiny project.
Btw I believe it will eventually happen again. @PEZ mentioned it might be a good idea to keep running vscode/calva in dev mode.
Maybe the best thing to do is to run that project in Calva dev mode. Then if this happens again, use the debugger to try find where it fails.
Is this easy to do? Is the Code+Calva usable in this mode? If so, I don't mind trying that - and in case it happens again, we can have a remote session or something. It would be great to track this issue down and be able to fix it.
You should be able to just clone Calva, open the repo in VS Code, then run ctrl+shift+b (Run Build Task), and once that says it's watching for file changes, hit F5 to run the Extension Development Host, then you use that window as your project window. Calva is usable just as usual in this mode. Thanks for doing that!
See here for more details: https://github.com/BetterThanTomorrow/calva/wiki/How-to-Hack-on-Calva
We have had similar issues before when the regexes of our Clojure lexer spins away. I wonder if that could be what is happening here.
@brdloush if this is the cause then it is probably just one of your files that is triggering the condition. See if you can figure out which file. If this is indeed the cause then the same file should immediately start to cause the issue when it is opened/activated. If we can find the file we can probably find what in it that Calva croaks on.
Reviving this to say that this has been happening consistently for me when I press tab to auto-format a section of particularly poorly-arranged code. At least, delete and backspace stop working. Reloading the window fixes it, and things are fine until I press tab again on the wrong line. It's hard to say what about the code is causing this, but this seems to further imply a connection to the formatting routine.
@andrewtoups Maybe can try to narrow the issue by copying smaller and smaller sections of code (bisecting the code in the file it happens in, basically), until you can reproduce with a very small set of code, then you can share that code here.