Fork me on GitHub
#calva
<
2021-10-20
>
pez10:10:21

Dear Calva friend: Please visit #announcements and add your reaction. 😃

🎉 1
pez12:10:05

Sweet feedback on this Youtube video: https://www.youtube.com/watch?v=O6GrXXhCzCc

🎉 8
👏 2
jussi13:10:27

Hi, I've had a really weird problem with Calva for better half of the day. Symptoms: Editor works for a while but after first tab key press I cannot anymore delete text (backspace/del) nor use shortcuts (eg. ctrl-alt-c ctrl-alt-j to jack-in etc). Calva version 2.0.220 VSCode version 1.61.2 Fedora 34 I've tried rolling back to older version (.216) to no avail. After upgrading to latest Calva and VS Code I started to see this error also.

[Error - 16:29:50] Starting client failed
Launching server using command /home/jmo/.vscode/extensions/betterthantomorrow.calva-2.0.220/clojure-lsp_backup failed.
Any ideas? Is this combo dysfunctional everything being latest versions?

jussi13:10:40

I don't have clojure-lsp installed locally.

pez13:10:16

You don’t need to. And the errors are unrelated.

ericdallo13:10:21

Calva install clojure-lsp automatically, so maybe it had some issue installing?

ericdallo13:10:36

oh, ok, it seems unrelated indeed

pez13:10:26

Still, probably clojure-lsp download failed and there was no backup because new Calva version.

pez13:10:57

See if you can get clojure-lsp working by reloading the VS Code window.

jussi13:10:15

Yeah, I know I don't neec clojure-lsp locally, just wanted to say it to clarify my isntallation 🙂

jussi13:10:43

Calva is utilizing cider-nrepl and clojure-lsp to create this VS Code experience.
  nREPL dependencies configured:
    nrepl: 0.8.3
    cider-nrepl: 0.26.0
    cider/piggieback: 0.5.2
 clojure-lsp version configured: latest

If you are new to Calva, please consider starting with the command:
  **Calva: Fire up the Getting Started REPL**
  

(See `showCalvaSaysOnStart` in Settings to control the auto-showing of this message panel.)

clojure-lsp version used: 2021.10.20-13.04.11
clj-kondo version used: 2021.10.19
It succeeds loading it most of the time

jussi13:10:21

Still, the symptoms are there, after trying to indent by pressing tab it happens again

pez13:10:18

As for the other error. A minimal repro would help. It is probably something with the text in the file that trips Calva up. If you can share the code, then I can help searching for the problem. Otherwise, try bisect it down.

jussi13:10:42

Ok, will try. It's cljs and I'm building a Vega spec (react-vega + fulcro) for a data visualisation

pez13:10:25

Does it matter which form you are formatting?

jussi13:10:42

It seems to, if I'm formattin fulcro cljs code it works, when I try to format the vega spec it starts to act weird

jussi13:10:07

(ns foo.vega
  (:require
   ["react-vega" :refer [Vega]]
   [com.fulcrologic.fulcro.algorithms.react-interop :as interop]
   [com.fulcrologic.fulcro.components :as comp :refer [defsc]]
   [com.fulcrologic.fulcro.dom :as dom]))

(def vega (interop/react-factory Vega))

(def vega-spec
  {"$schema" ""
   "description" "An example of treemap layout for hierarchical data."
   "width" 660
   "height" 500
   "padding" 2.5
   "autosize" "none"

   "data" [{"name" "table"
            "url" "/public.json"
            "format" {"type" "json", "parse" "auto"}
            "transform" [#_{"type" "stack"
                            "groupby" ["TravelEndDate"]
                            "sort" {"field" "type"}
                            "field" "fig01"}
                         {"type" "timeunit"
                          "field" "TravelEndDate"
                          "units" ["year" "month"]
                          "signal" "tbin"}
                         {"type" "aggregate"
                          "groupby" ["unit0" "type"]
                          "ops" ["sum" "count"]
                          "fields" ["fig01" "fig01"]
                          "as" ["fig01" "eventCount"]}
                         {"type" "stack"

                          "groupby" ["unit0"]
                          "sort" {"field" "type"}
                          "field" "fig01"}]}]

   "title" "asdasd"
   "scales" [{"name" "x"
              "type" "band"
              "range" "width"
              "domain" {"signal" "timeSequence(tbin.unit, tbin.start, tbin.stop)"}
              #_#_"domain" {"data" "table", "field" "unit0"}}
             {"name" "y"
              "type" "linear"
              "range" "height"
              "nice" true, "zero" true
              "domain" {"data" "table", "field" "y1"}}
             {"name" "color"
              "type" "ordinal"
              "range" "category"
              "domain" {"data" "table", "field" "type"}}]

   "axes" [{"orient" "bottom"
            "scale" "x"
            "zindex" 1
            "title" "Time"
            "titleAnchor" "middle"
            "formatType" "time"
            "format" {"signal" "timeUnitSpecifier(tbin.unit, {'year-month': '%Y-%m'})"}}
           {"orient" "left",
            "scale" "y",
            "title" "fig01 in kg's"
            "titleAngle" 90
            "titleAnchor" "middle"
            "format" "d"
            "zindex" 1,
            "tickCount" 10}]

   "marks" [{"type" "rect"
             "tooltip" "true"
             "from" {"data" "table"}
             "encode" {"update" {"x" {"scale" "x", "field" "unit0"}
                                 "width" {"scale" "x", "band" 1, "offset" -1}
                                 "y" {"scale" "y", "field" "y0"}
                                 "y2" {"scale" "y", "field" "y1"}
                                 "fill" {"scale" "color", "field" "type"}
                                 "fillOpacity" {"value" 1}}
                       "hover" {"fillOpacity" {"value" 0.5}
                                "tooltip" {"signal" "{'Type': datum.type, 'Events': datum.eventCount, 'fig01': format(datum.fig01, 'r') + 'kg'}"}}}}]})

(defsc SomeChart [_this _props]
  (dom/div {:style {:padding-left "30px"}}
           (vega {:spec (clj->js vega-spec)})))
(def some-chart (comp/factory SomeChart))
Here's the file that causes the problems. When adding a new item to vega-spec eg. after autosize adding a "title" {"text" "title"} and then indenting starts the funny stuff

pez14:10:07

I can reproduce. Super weird.

pez14:10:23

Now I can’t reproduce it
 Hmmm
 What if it is related to clojure-lsp failing to start anyway
 You said it load most of the time, can you see a pattern that this tab freezup happens when clojure-lsp loads and when it doesn’t?

jussi16:10:19

can't really see it, there are no real error messages but that does sound plausible

pez17:10:59

Doesn’t sound plausible to me. 😃

😁 1
pez17:10:18

When it happens I get an error in the development console (available from the Help menu) about Calva consuming tons of the CPU for almost 5 secs. (Which is VS Codes way to tell you an extension has locked up.)

jussi06:10:47

Yep, I see it too.

WARN UNRESPONSIVE extension host, 'betterthantomorrow.calva' took 78% of 6436.194ms, saved PROFILE here: 'file:///tmp/exthost-e72a36.cpuprofile' 

0:
   id: "betterthantomorrow.calva"
   percentage: 78
   total: 5000294
   __proto__: Object
1:
   id: "program"
   percentage: 22
   total: 1435137
   __proto__: Object
   length: 2
   __proto__: Array(0)

jussi07:10:55

Got this just now after pressing tab to do formatting

Running the contributed command: 'calva-fmt.formatCurrentForm' failed.

Hukka12:10:00

Started running into this too now. Not even using the tab, but just paredit on somewhat large maps (tens of lines, six levels of nesting)

pez14:10:45

Can you make a minimal repro from it, @U8ZQ1J1RR?

pez14:10:17

Was it in 2.0.221 you ran into it?

Hukka14:10:18

216 and 221.

Hukka14:10:30

I can't make it very minimal, this is as small as I can get:

Hukka14:10:58

To see it happen, go to the map that is the value in vega-spec/mark, and try to ctrl-alt-comma (and dot) to make the map larger or smaller, after one or three times, calva freezes

Hukka14:10:09

Here's the crazy thing: if I remove the defsc, or scales, or axes, or marks, or even the encode inside mark - legends, it won't do that anymore. Only if it's that big. I didn't try removing everything line by line, but anything "major" like that and the bug does not manifest

Hukka14:10:14

No idea what is important here. At my resolution that is a bit more than I can fit on screen at the same time. But yet, if I for example replace the "marks" value with a simpler map of just integer keys and values, large enough that it won't fit on the screen, it won't bug

Hukka14:10:27

I tested this by putting a file "vega.cljs" inside a folder "calva-repro", with that content, and strting with code calva-repro. Nothing more in the folder; no deps.edn, nothing

Hukka14:10:50

And it happens 100% to me after one or two tries.

Hukka14:10:39

(I mean one or two barf/slurp sexp forwards, not one or two restarts of vscode)

Hukka14:10:35

I'm bisecting the version now. 160 is broken, 100 works

❀ 1
Hukka14:10:40

145 is the last working version

Hukka14:10:27

146 seems to have some slurp forward fix, but now I have to feed kids (not goats!)

pez14:10:11

Awesome hunting, @U8ZQ1J1RR!

pez14:10:37

Slurp forward is not happening at tab, but something in that fix could have been in the token cursor code, and that’s probably where we run into some infinite loop.

Hukka17:10:16

IF it helps, I can see if I can get a profile out of it. Should show where it's stuck

Hukka17:10:34

4,994.68ms
4,994.68ms
(anonymous)
../../.vscode/extensions/gruntfuggly.todo-tree-0.0.214/dist/extension.js:52
4,994.68ms
4,994.68ms
(anonymous)
../../.vscode/extensions/gruntfuggly.todo-tree-0.0.214/dist/extension.js:52
4,994.68ms
4,994.68ms
calva$fmt$util$re_pos_first
.shadow-cljs/builds/calva-lib/dev/out/cljs-runtime/calva.fmt.util.js:58
4,994.68ms
4,994.68ms
calva$fmt$formatter$index_for_tail_in_range
.shadow-cljs/builds/calva-lib/dev/out/cljs-runtime/calva.fmt.formatter.js:127
4,994.68ms
4,994.68ms
calva$fmt$formatter$format_text_at_idx
.shadow-cljs/builds/calva-lib/dev/out/cljs-runtime/calva.fmt.formatter.js:264
4,994.68ms
4,994.68ms
calva$fmt$formatter$format_text_at_idx_bridge
.shadow-cljs/builds/calva-lib/dev/out/cljs-runtime/calva.fmt.formatter.js:271
4,994.68ms
4,994.68ms
_formatIndex
src/calva-fmt/src/format.ts:129
4,994.68ms
4,994.68ms
formatPositionInfo
src/calva-fmt/src/format.ts:45
4,994.68ms
4,994.68ms
formatPosition
src/calva-fmt/src/format.ts:78
4,994.68ms
4,994.68ms
(anonymous)
src/doc-mirror/index.ts:38
4,994.68ms
4,994.68ms
runMicrotasks
4,994.68ms
4,994.68ms
processTicksAndRejections
<node_internals>/internal/process/task_queues.js:65

Hukka18:10:24

Argh! After being stuck for 20 minutes, and my looking through the code, it got unstuck! And cannot get stuck again!

Hukka18:10:13

I have no idea what's happening, nor any idea where to look for an explanation

Hukka18:10:14

Well, restarting will make it stuck again. Just that one instance was unstuckable

Hukka18:10:52

In any case, I couldn't much make sense what could be stuck in that stack trace. Also checked the commits between 146 and 145, can't figure it out from there either

Hukka18:10:14

I guess I lack the necessary knowledge on developing vscode extensions to look at the right place

Hukka18:10:22

I don't even know what that other extension is doing in that stacktrace. Disabling it doesn't do anything, for what's it worth

pez18:10:55

I'll check the commits.

pez18:10:50

You have helped tremendously!

Hukka18:10:27

I hope so!

Hukka19:10:01

Hm, in the normal calva (not running via the source code checkout) waiting does get it unstuck, but it gets stuck right after barfing more

Zach Mitchell22:10:10

I see a common workflow is to put some dev-time functions in a user.clj file. In Calva however when you send something to the REPL it switches the namespace you're in, which means you're no longer in the user namespace and can no longer (effortlessly) access those functions. Is there a convenient way around this or a different workflow?

Hukka05:10:13

I've never stayed in the user ns, not in calva nor previously. What I always do is to use fully qualified names for whatever is in there, so things like (user/start), (user/restart)

Hukka05:10:39

Especially handy with autocomplete / history

👀 2
pez08:10:15

Ah, that with autocomplete / history is a very good point. Thanks for sharing!

pez08:10:59

You can also make a custom REPL snippet that does something like (in-ns 'user) and give it the key "u" which will bind it to ctrl+space u. I think that with the use of some atom you could bind ctrl+space - to take you back to whatever namespace you came from. (Not sure, but it is Clojure after all so anything should be possible. 😃)

pez08:10:32

What I do is that I open user.clj and use rich comments in there. And if you load that file it will switch the REPL window to that namespace.