Fork me on GitHub
#clerk
<
2023-12-31
>
Alex13:12:29

Hi! I have a personal notes project based off clerk-demo, which I upgraded to use the latest clerk recently (`0.15.957`). I noticed that often (but not always) after I save a watched .clj file, the web page will first update and then jump to the index page. Anyone else seeing the same? Did I mess something up in my deps.edn: https://github.com/a1exsh/notes/blob/main/deps.edn#L12-L21 ? I the repl I see unexpected Clerk evaluated 'jar:file:/home/ash/.m2/repository/io/github/nextjournal/clerk/0.15.957/clerk-0.15.957.jar!/nextjournal/clerk/index.clj' in 79.353063ms. after it evals my file.

mkvlr14:12:39

Hi Alex, newer versions of Clerk update the shown notebook as a result of an url update in the browser. I believe what you’re seeing here might be a result of that. Is one of your notebooks maybe requesting a local file that could cause this?

mkvlr14:12:54

or doing a request to /?

Alex14:12:09

no, nothing like that. I've tried to inspect the requests that the webpage is doing and it suddenly stopped reproducing, but I got this error in the JS console:

Uncaught TypeError: URL constructor:  is not a valid URL.
    PL render.cljs:650
    b render.cljs:723
    aM render.cljs:721
    Ela events.js:453
    a events.js:213
    yla listenermap.js:305
    Lv listener.js:71
    dM render.cljs:740
    hM render.cljs:750
    <anonymous> macros:432
render.cljs:650:5
    PL render.cljs:650
    b render.cljs:723
    aM render.cljs:721
    Ela events.js:453
    a events.js:213
    (Async: EventListener.handleEvent)
    yla listenermap.js:305
    Lv listener.js:71
    dM render.cljs:740
    hM render.cljs:750
    <anonymous> macros:432

Alex14:12:22

this is the code and the line that fails:

Alex14:12:55

@U5H74UNSF does that look familiar to you? because I don't know where to look next

mkvlr14:12:06

@U04CRS4B49L the code is public, right? How can I repro this?

Alex15:12:55

yes, just clone it and then navigate to macros.clj, for example. for me it almost always results in render + redirect to index

mkvlr15:12:31

navigate how?

mkvlr15:12:39

haven’t been able to reproduce it yet

mkvlr15:12:10

would recommend trying the latest git sha of clerk as well

mkvlr15:12:30

tried the file watcher and running clerk show manually but failing to repro either way

mkvlr15:12:38

what browser are you using?

Alex15:12:26

> navigate how? from the index page after running serve!

Alex15:12:07

let me try the latest commit though

mkvlr15:12:08

so clicking here?

mkvlr15:12:46

also can’t repro in firefox

Alex15:12:03

(latest git version greets me with this error on the index page):

Uncaught DOMException: An attempt was made to use an object that is not, or is no longer, usable
    ws_send sci_env.cljs:220
    HL render.cljs:561
    h render.cljs:653
    j render.cljs:536
    hM render.cljs:725
    Dla events.js:454
    a events.js:216
viewer.js:5911

mkvlr15:12:42

can you try deleting the clerk cache?

Alex15:12:53

with (clerk/clear-cache!)?

mkvlr15:12:06

not seeing the error

Alex15:12:18

so far I didn't repro my original problem with the latest git

👍 2
Alex15:12:03

OK, but why this now?

Alex15:12:49

I didn't change my :exec-args

mkvlr16:12:33

hmm, not 100% sure either if this is intentional anymore, cc @U9EQP1K0X

mkvlr16:12:08

I think we did more guesswork previously to infer the :paths but have decided to stop doing that

mkvlr16:12:44

but not 100% sure anymore

Alex16:12:57

but I do specify them: https://github.com/a1exsh/notes/blob/main/deps.edn#L14 <= is that not correct?

mkvlr16:12:10

this doesn’t also pass them to clerk/serve! try passing the same as a an arg

Alex16:12:06

like so: (clerk/serve! {:paths ["src/*.clj"] :watch-paths ["src"] :port 6677 :browse? true}) ?

Alex16:12:15

that has slightly different effects

Alex16:12:55

namely, I don't get Home and Index pages at all this way

mkvlr16:12:07

shouldn’t this be {:paths ["notebooks/*.clj"] ,,,?

Alex16:12:27

sorry, context switching. let me try again %)

Alex16:12:30

yeah, the same problem — it somehow jumps straight to macros and no Home or Index:

mkvlr16:12:33

I see this

mkvlr16:12:04

with the following command (clerk/serve! {:browse? true :port 6677 :paths ["notebooks/*.clj"]})

Alex16:12:42

bummer, I removed the other two files locally while debugging the original issue. now I see the same

Alex16:12:51

but where is the Home page now? that was useful

mkvlr16:12:50

setting :paths intentionally disables it

Alex17:12:54

Okay... no pressing issue at the moment, so I guess I can live with that. Thanks a lot for the tips! 🙂

Andrea10:01:46

> hmm, not 100% sure either if this is intentional anymore @U5H74UNSF The code path which reads from nextjournal/clerk alias in deps.edn is still there but is bypassed by this binding https://github.com/nextjournal/clerk/blob/f8377d6116ccecee00ecf1dcc2fa843555cac9d8/src/nextjournal/clerk.clj#L71-L72 I’ll file an issue.

👍 2
Alex09:01:56

@U5H74UNSF @U9EQP1K0X is there a chance to cover this with a test, so that it doesn't break next time again?.. 😉 I'm really grateful for Clerk being there, but my experience is too often: - upgrade to the latest commit to fix an issue; - discover that something else doesn't work anymore; - repeat

jackrusher16:01:53

@U04CRS4B49L There will be breaking changes from time to time until version 1.0 ships. We’re still actively working on a number of details and APIs. Once things solidify, we’ll bring them under test, as we’ve been gradually doing for the parts we’re pretty sure are baked. In the meanwhile, I can only offer apologies for occasional annoyances.

Alex17:01:16

@U07SQTAEM that makes sense, I wouldn't want to trip over failing tests while evolving the API myself. Thanks once again! :)

🖤 1
Alex16:12:34

Hm, it looks like top-to-bottom evaluation doesn't play along with forward declarations... Is there a trick that I'm missing?

Andrea11:01:15

clerk should handle forward declarations, could you share some details of what’s going wrong for you?

Alex12:01:41

I'll try to reproduce. What I observed was stale results from expressions that depend on the definition.

Andrea12:01:43

sounds like a caching issue

Alex13:01:40

I remember thinking that and trying to clear the cache, but that was not helping. I'm generally doing my homework before complaining. ;)

Alex10:01:39

Cannot reproduce it now in isolation. Will come back here if I hit it again.

Alex10:01:15

There is one quirk though: https://github.clerk.garden/a1exsh/notes/commit/3e5f1a8b467784b9b4b8c96f423600b0a6d4e1fa/notebooks/declare/ I understand that Clerk is trying to be helpful (or is it accidental?), but the behavior is then different when actually evaluating top to bottom.

Alex07:01:53

@U9EQP1K0X can you comment — is this by design or a quirk? Should I rather open a github issue? 🙂

Andrea09:01:48

I don’t think this is intentional, but I might be wrong, @U5H74UNSF any insights?

Andrea11:01:22

@U04CRS4B49L we had a related issue already, I added your remarks there https://github.com/nextjournal/clerk/issues/454

👍 1