clerk

Alex 2023-12-31T13:07:29.826589Z

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.

Andrea 2024-01-02T10:19:46.507689Z

> hmm, not 100% sure either if this is intentional anymore @mkvlr 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
2024-01-17T16:10:53.711129Z

@alex.shulgin 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.

Alex 2024-01-17T17:20:16.367239Z

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

🖤 1
Alex 2024-01-04T09:19:56.195209Z

@mkvlr @andrea712 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

mkvlr 2023-12-31T14:16:39.578509Z

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?

mkvlr 2023-12-31T14:16:54.438129Z

or doing a request to /?

Alex 2023-12-31T14:33:09.042599Z

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

Alex 2023-12-31T14:34:22.712649Z

this is the code and the line that fails:

Alex 2023-12-31T14:40:55.392469Z

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

mkvlr 2023-12-31T14:48:06.367419Z

@alex.shulgin the code is public, right? How can I repro this?

Alex 2023-12-31T15:02:55.818509Z

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

mkvlr 2023-12-31T15:40:31.228189Z

navigate how?

mkvlr 2023-12-31T15:40:39.400839Z

haven’t been able to reproduce it yet

mkvlr 2023-12-31T15:42:10.595089Z

would recommend trying the latest git sha of clerk as well

mkvlr 2023-12-31T15:42:30.503229Z

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

mkvlr 2023-12-31T15:42:38.517139Z

what browser are you using?

Alex 2023-12-31T15:43:00.141719Z

Firefox

Alex 2023-12-31T15:43:26.800179Z

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

Alex 2023-12-31T15:44:07.732229Z

let me try the latest commit though

mkvlr 2023-12-31T15:45:08.128549Z

so clicking here?

Alex 2023-12-31T15:46:34.585559Z

yep

mkvlr 2023-12-31T15:46:46.589669Z

also can’t repro in firefox

Alex 2023-12-31T15:47:03.160809Z

(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

mkvlr 2023-12-31T15:47:42.570549Z

can you try deleting the clerk cache?

Alex 2023-12-31T15:48:53.574809Z

with (clerk/clear-cache!)?

mkvlr 2023-12-31T15:49:59.127879Z

yep

mkvlr 2023-12-31T15:50:06.250069Z

not seeing the error

Alex 2023-12-31T15:50:18.014599Z

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

👍 2
Alex 2023-12-31T15:53:03.337239Z

OK, but why this now?

Alex 2023-12-31T15:54:49.776439Z

I didn't change my :exec-args

mkvlr 2023-12-31T16:07:33.536769Z

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

mkvlr 2023-12-31T16:19:08.137069Z

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

mkvlr 2023-12-31T16:19:44.558069Z

but not 100% sure anymore

Alex 2023-12-31T16:19:57.420989Z

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

mkvlr 2023-12-31T16:31:10.431859Z

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

Alex 2023-12-31T16:34:06.990549Z

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

Alex 2023-12-31T16:34:15.444939Z

that has slightly different effects

Alex 2023-12-31T16:43:55.050649Z

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

mkvlr 2023-12-31T16:46:07.720659Z

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

Alex 2023-12-31T16:46:27.680949Z

sorry, context switching. let me try again %)

Alex 2023-12-31T16:48:30.860309Z

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

mkvlr 2023-12-31T16:52:33.093219Z

I see this

mkvlr 2023-12-31T16:53:04.941099Z

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

Alex 2023-12-31T16:55:42.482669Z

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

Alex 2023-12-31T16:55:51.801709Z

but where is the Home page now? that was useful

mkvlr 2023-12-31T16:59:50.685849Z

setting :paths intentionally disables it

Alex 2023-12-31T17:00:54.410289Z

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

Alex 2023-12-31T16:25:34.053129Z

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

Alex 2024-01-09T07:22:53.576149Z

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

Andrea 2024-01-09T09:24:48.231079Z

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

Andrea 2024-01-09T11:01:22.685899Z

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

👍 1
Andrea 2024-01-02T11:43:15.593769Z

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

Alex 2024-01-02T12:46:41.720849Z

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

Andrea 2024-01-02T12:47:43.433349Z

sounds like a caching issue

Alex 2024-01-02T13:04:40.996559Z

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

Alex 2024-01-04T10:28:39.629669Z

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

Alex 2024-01-04T10:35:15.649679Z

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.