scittle

2023-11-19T18:47:35.714789Z

Hello, I'm trying to add a plugin for Hoplon but I'm getting this error when running bb dev on the demo folder after my changes:

[:main] Build failure:
------ ERROR -------------------------------------------------------------------
 File: /home/y/.gitlibs/libs/io.github.babashka/sci.configs/08bab21643bc0c63a5b99c65193c9d24888270b7/src/sci/configs/funcool/promesa.cljs:183:13
--------------------------------------------------------------------------------
 180 |    'do! (sci/copy-var do! pns)
 181 |    'done? (sci/copy-var p/done? pns)
 182 |    'error (sci/copy-var p/error pns)
 183 |    'extract (sci/copy-var p/extract pns)
-------------------^------------------------------------------------------------
null
Unable to resolve var: extract in this context at line 183 sci/configs/funcool/promesa.cljs
--------------------------------------------------------------------------------
 184 |    'finally (sci/copy-var p/finally pns)
 185 |    'future (sci/copy-var future pns)
 186 |    'thread-call (sci/copy-var p/thread-call pns)
 187 |    'handle (sci/copy-var p/handle pns)
--------------------------------------------------------------------------------

borkdude 2023-11-19T18:49:43.738009Z

you probably need to bump promesa

2023-11-19T18:50:52.172779Z

Ok, trying again.

2023-11-19T18:52:07.839119Z

error.cljs:7 ----- Scittle error ------------------------------
eval @ error.cljs:7
scittle$impl$error$ruler @ error.cljs:10
scittle$impl$error$error_handler @ error.cljs:65
scittle$core$eval_string @ core.cljs:71
scittle$core$eval_script_tags_STAR_ @ core.cljs:97
scittle$core$eval_script_tags @ core.cljs:103
eval @ core.cljs:116
error.cljs:7 Message:  No context found in: sci.ctx-store/*ctx*. Please set it using sci.ctx-store/reset-ctx!
eval @ error.cljs:7
scittle$impl$error$error_handler @ error.cljs:70
scittle$core$eval_string @ core.cljs:71
scittle$core$eval_script_tags_STAR_ @ core.cljs:97
scittle$core$eval_script_tags @ core.cljs:103
eval @ core.cljs:116
error.cljs:7 Location: scittle-tag-1:6:11
eval @ error.cljs:7
scittle$impl$error$error_handler @ error.cljs:76
scittle$core$eval_string @ core.cljs:71
scittle$core$eval_script_tags_STAR_ @ core.cljs:97
scittle$core$eval_script_tags @ core.cljs:103
eval @ core.cljs:116
error.cljs:7 ----- Context ------------------------------------
eval @ error.cljs:7
scittle$impl$error$ruler @ error.cljs:10
scittle$impl$error$error_handler @ error.cljs:83
scittle$core$eval_string @ core.cljs:71
scittle$core$eval_script_tags_STAR_ @ core.cljs:97
scittle$core$eval_script_tags @ core.cljs:103
eval @ core.cljs:116
error.cljs:7 
2        (require '[javelin.core :as j])
3  
4  (j/defc title "From Hoplon")
5  (h/body 
6      (h/h1 (h/text "~{title}")))
             ^--- No context found in: sci.ctx-store/*ctx*. Please set it using sci.ctx-store/reset-ctx!
eval @ error.cljs:7
scittle$impl$error$error_handler @ error.cljs:84
scittle$core$eval_string @ core.cljs:71
scittle$core$eval_script_tags_STAR_ @ core.cljs:97
scittle$core$eval_script_tags @ core.cljs:103
eval @ core.cljs:116
error.cljs:7 ----- Stack trace --------------------------------
eval @ error.cljs:7
scittle$impl$error$ruler @ error.cljs:10
scittle$impl$error$error_handler @ error.cljs:91
scittle$core$eval_string @ core.cljs:71
scittle$core$eval_script_tags_STAR_ @ core.cljs:97
scittle$core$eval_script_tags @ core.cljs:103
eval @ core.cljs:116
error.cljs:7 user             - scittle-tag-1:6:11 
clojure.core/let - <built-in> 
user/with-let    - scittle-tag-1:6:11 
user             - scittle-tag-1:6:11 
user/text        - scittle-tag-1:6:11 
...
user             - scittle-tag-1:6:11 
user/body        - scittle-tag-1:6:5 
user             - scittle-tag-1:6:5 
user             - scittle-tag-1:5:1 
user             - scittle-tag-1:5:1 

eval @ error.cljs:7
scittle$impl$error$error_handler @ error.cljs:92
scittle$core$eval_string @ core.cljs:71
scittle$core$eval_script_tags_STAR_ @ core.cljs:97
scittle$core$eval_script_tags @ core.cljs:103
eval @ core.cljs:116
core.cljs:72 Uncaught cljs$core$ExceptionInfo {message: 'No context found in: sci.ctx-store/*ctx*. Please set it using sci.ctx-store/reset-ctx!', data: {…}, cause: Error: No context found in: sci.ctx-store/*ctx*. Please set it using sci.ctx-s

2023-11-19T18:52:21.364339Z

On the browser console now.

borkdude 2023-11-19T18:57:01.455949Z

We need to update scittle itself to store the context like is done here: https://github.com/babashka/nbb/blob/e270785599bb9af605d684b02c3ad40b186e736f/src/nbb/core.cljs#L587

borkdude 2023-11-19T18:57:20.714329Z

And everywhere in the code where the context is used, you must use sci.ctx-store/get-context

2023-11-19T19:04:13.451179Z

Should that be sci.ctx-store/get-ctx?

borkdude 2023-11-19T19:04:51.692149Z

yes

2023-11-19T19:08:39.930059Z

error.cljs:7 ----- Scittle error ------------------------------
eval @ error.cljs:7
scittle$impl$error$ruler @ error.cljs:10
scittle$impl$error$error_handler @ error.cljs:65
scittle$core$eval_string @ core.cljs:72
scittle$core$eval_script_tags_STAR_ @ core.cljs:98
scittle$core$eval_script_tags @ core.cljs:104
eval @ core.cljs:117
error.cljs:7 Message:  Cannot read properties of null (reading 'substring')
eval @ error.cljs:7
scittle$impl$error$error_handler @ error.cljs:70
scittle$core$eval_string @ core.cljs:72
scittle$core$eval_script_tags_STAR_ @ core.cljs:98
scittle$core$eval_script_tags @ core.cljs:104
eval @ core.cljs:117
error.cljs:7 Location: scittle-tag-1:6:11
eval @ error.cljs:7
scittle$impl$error$error_handler @ error.cljs:76
scittle$core$eval_string @ core.cljs:72
scittle$core$eval_script_tags_STAR_ @ core.cljs:98
scittle$core$eval_script_tags @ core.cljs:104
eval @ core.cljs:117
error.cljs:7 ----- Context ------------------------------------
eval @ error.cljs:7
scittle$impl$error$ruler @ error.cljs:10
scittle$impl$error$error_handler @ error.cljs:83
scittle$core$eval_string @ core.cljs:72
scittle$core$eval_script_tags_STAR_ @ core.cljs:98
scittle$core$eval_script_tags @ core.cljs:104
eval @ core.cljs:117
error.cljs:7 
2        (require '[javelin.core :as j])
3  
4  (j/defc title "From Hoplon")
5  (h/body 
6      (h/h1 (h/text "~{title}")))
             ^--- Cannot read properties of null (reading 'substring')
eval @ error.cljs:7
scittle$impl$error$error_handler @ error.cljs:84
scittle$core$eval_string @ core.cljs:72
scittle$core$eval_script_tags_STAR_ @ core.cljs:98
scittle$core$eval_script_tags @ core.cljs:104
eval @ core.cljs:117
error.cljs:7 ----- Stack trace --------------------------------
eval @ error.cljs:7
scittle$impl$error$ruler @ error.cljs:10
scittle$impl$error$error_handler @ error.cljs:91
scittle$core$eval_string @ core.cljs:72
scittle$core$eval_script_tags_STAR_ @ core.cljs:98
scittle$core$eval_script_tags @ core.cljs:104
eval @ core.cljs:117
error.cljs:7 user             - scittle-tag-1:6:11 
clojure.core/let - <built-in> 
user/with-let    - scittle-tag-1:6:11 
user             - scittle-tag-1:6:11 
user/text        - scittle-tag-1:6:11 
...
user             - scittle-tag-1:6:11 
user/body        - scittle-tag-1:6:5 
user             - scittle-tag-1:6:5 
user             - scittle-tag-1:5:1 
user             - scittle-tag-1:5:1 

eval @ error.cljs:7
scittle$impl$error$error_handler @ error.cljs:92
scittle$core$eval_string @ core.cljs:72
scittle$core$eval_script_tags_STAR_ @ core.cljs:98
scittle$core$eval_script_tags @ core.cljs:104
eval @ core.cljs:117
core.cljs:73 Uncaught cljs$core$ExceptionInfo {message: "Cannot read properties of null (reading 'substring')", data: {…}, cause: TypeError: Cannot read properties of null (reading 'substring')
    at Function.eval [as cljs$core$…, name: 'Error', description: undefined, …}
This is after fixing the code to get/set context.

borkdude 2023-11-19T19:13:14.486439Z

Can you make a PR to show what you have tried?

borkdude 2023-11-19T19:16:45.307729Z

looks correct to me

borkdude 2023-11-19T19:17:28.346049Z

I think I know what's going wrong, the sources are saved in the context but sci/merge-opts doesn't preserve that key

borkdude 2023-11-19T19:17:43.263199Z

something like that probably

borkdude 2023-11-19T19:18:00.958529Z

perhaps you can save the sources in another mutable thing

borkdude 2023-11-19T19:18:25.889549Z

not sure if it's that but it seems something like it

2023-11-19T19:25:08.416119Z

You mean that this problem should be related to advanced compilation?

borkdude 2023-11-19T19:28:40.688489Z

no

borkdude 2023-11-19T19:28:52.147369Z

with sources I mean the sources from the script tags

borkdude 2023-11-19T19:29:42.813459Z

just try to debug the core.cljs namespace a bit with print statements

2023-11-19T19:56:22.857469Z

I think this is something related to the h/text macro. I tried some other hoplon code, and it seems to be working.

borkdude 2023-11-19T19:57:15.641639Z

could be since h/text needs the context to be available in sci.ctx-store

borkdude 2023-11-19T19:57:58.311209Z

I can take a look later this week if you're stuck

2023-11-19T19:59:51.888639Z

Ok, I think I'm understanding better what is going on. I will try to poke around a bit more with a local sci.config.

2023-11-20T13:12:01.288159Z

In the end I don't think this is related to context. I found that almost everything is working including h/text depending on the input.

borkdude 2023-11-20T13:14:09.455569Z

have you still got the sci.ctx-store in place?

borkdude 2023-11-20T13:15:02.921039Z

you absolutely need to do this: https://github.com/babashka/sci.configs/blob/91c8eb918c80edaa0c1440070023a05b662538aa/playground/src/playground.cljs#L78 else h/text will not work

borkdude 2023-11-20T13:16:28.193139Z

or wait, probably I'm confusing something. you need sci.ctx-store for macroexpand: https://github.com/babashka/sci.configs/blob/91c8eb918c80edaa0c1440070023a05b662538aa/src/sci/configs/hoplon/hoplon.cljs#L58

borkdude 2023-11-20T13:16:47.746399Z

h/text is probably fine without that

borkdude 2023-11-20T13:16:51.836489Z

but could be an edge case there

2023-11-20T13:16:59.335319Z

I think scittle takes care of that? I only have some version changes and the index of the demo I'm using for that.

2023-11-20T13:17:30.956699Z

I think that nil is getting somewhere a string is expected on that case.

borkdude 2023-11-20T13:17:46.542389Z

> I think scittle takes care of that? Yes, if you made those changes to scittle, else, not yet I think

borkdude 2023-11-20T13:18:12.576739Z

yes, that is what I meant with "the sources" from the tags are stored in the context and they are probably getting lost due to a merge options

2023-11-20T13:18:15.915059Z

Yeah, I'm on the branch of that pr I opened and it has the changes.

borkdude 2023-11-20T13:18:21.226949Z

so the source is nil and then you get a nil pointer

borkdude 2023-11-20T13:18:49.589509Z

just read the source of how the tags are being inspected and where the result is stored

borkdude 2023-11-20T13:18:59.320259Z

you can just save those things elsewhere, in a separate atom or so

borkdude 2023-11-20T13:19:13.414899Z

saving them in the context was a bit of a hack anyway

2023-11-20T13:20:46.339569Z

That is what I'm trying to explain. I don't think this is the problem. I think it is the macro that has an edge case for some inputs. The h/text macro doesn't use macroexpand.

borkdude 2023-11-20T13:21:56.367289Z

make a minimal repro that we can use in the sci.configs playground

borkdude 2023-11-20T13:22:18.923819Z

it does work for some other example in your case?

2023-11-20T13:22:33.364079Z

The code works on the playground but doesn't as a scittle plugin.\

borkdude 2023-11-20T13:22:51.163929Z

Then why do you think it's related to h/text?

2023-11-20T13:23:46.370399Z

Now that you mentioned it, you are right. My hypothesis makes no sense.

borkdude 2023-11-20T13:24:43.017819Z

the stacktrace is leading to here:

eval @ error.cljs:7
scittle$impl$error$error_handler @ error.cljs:92
scittle$core$eval_string @ core.cljs:72
scittle$core$eval_script_tags_STAR_ @ core.cljs:98
scittle$core$eval_script_tags @ core.cljs:104
Just place a couple of printlns in there to inspect what is going wrong.

borkdude 2023-11-20T13:25:40.501749Z

take smaller steps and make smaller repros (and use lots of println)

2023-11-20T13:25:51.159609Z

Ok, will do.

2023-11-20T13:29:11.559329Z

Cannot reproduce. I bumped sci to the latest version and the error is gone. I thought that the code that was returning an error was still broken but it isn't. Everything is working now. 😅

borkdude 2023-11-20T13:29:28.832159Z

lol :)

2023-11-20T17:20:06.234039Z

wow thanks you guys for working through this, extremely excited

2023-11-20T17:39:11.291979Z

@alandipert This seems to be done. I'm testing everything in a html page using hoplon as a scittle plugin. I still need to publish the plugin but if you want you can build locally from https://github.com/babashka/scittle/pull/73 Go to the plugins/demo folder and run npm install them bb dev http://localhost:1341 will serve the html from plugins/demo/resources/public/index.html

1
borkdude 2023-11-20T17:39:46.139689Z

merged

🎉 1
2023-11-20T18:38:38.625529Z

just noticed the demo readme is now wrong (the demo makes hoplon, not datascript now) i can send a PR when i play with it unless someone beats me to it

2023-11-20T18:39:03.525149Z

(also no objection from me for the demo default to be hoplon 😎 )

borkdude 2023-11-20T18:47:25.883879Z

not sure what you're referring to but PRs welcome :)

👍 1
borkdude 2023-11-20T18:55:16.808629Z

I guess we can leave datascript in as well?

2023-11-20T18:55:56.263809Z

if you like, and i can augment the demo code to exercise both?

2023-11-20T18:56:17.807909Z

(or we can go back to datascript, just lmk and i can update the PR)

borkdude 2023-11-20T19:01:03.562179Z

yeah, it's fine I guess

borkdude 2023-11-20T19:01:05.545109Z

merged

1
2023-11-19T18:49:22.889829Z

The changes I made: https://github.com/babashka/scittle/compare/main...mynomoto:scittle:main There are 2 commits, the first one attempting to add 2 plugins and the other one trying to add only a single plugin. Both are returning the same error.