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)
--------------------------------------------------------------------------------you probably need to bump promesa
Ok, trying again.
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-sOn the browser console now.
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
And everywhere in the code where the context is used, you must use sci.ctx-store/get-context
Should that be sci.ctx-store/get-ctx?
yes
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.Can you make a PR to show what you have tried?
looks correct to me
I think I know what's going wrong, the sources are saved in the context but sci/merge-opts doesn't preserve that key
something like that probably
perhaps you can save the sources in another mutable thing
not sure if it's that but it seems something like it
You mean that this problem should be related to advanced compilation?
no
with sources I mean the sources from the script tags
just try to debug the core.cljs namespace a bit with print statements
I think this is something related to the h/text macro. I tried some other hoplon code, and it seems to be working.
could be since h/text needs the context to be available in sci.ctx-store
I can take a look later this week if you're stuck
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.
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.
have you still got the sci.ctx-store in place?
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
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
h/text is probably fine without that
but could be an edge case there
I think scittle takes care of that? I only have some version changes and the index of the demo I'm using for that.
I think that nil is getting somewhere a string is expected on that case.
> I think scittle takes care of that? Yes, if you made those changes to scittle, else, not yet I think
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
Yeah, I'm on the branch of that pr I opened and it has the changes.
so the source is nil and then you get a nil pointer
just read the source of how the tags are being inspected and where the result is stored
you can just save those things elsewhere, in a separate atom or so
saving them in the context was a bit of a hack anyway
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.
make a minimal repro that we can use in the sci.configs playground
it does work for some other example in your case?
The code works on the playground but doesn't as a scittle plugin.\
Then why do you think it's related to h/text?
Now that you mentioned it, you are right. My hypothesis makes no sense.
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.take smaller steps and make smaller repros (and use lots of println)
Ok, will do.
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. 😅
lol :)
wow thanks you guys for working through this, extremely excited
@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
merged
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
(also no objection from me for the demo default to be hoplon 😎 )
not sure what you're referring to but PRs welcome :)
I guess we can leave datascript in as well?
if you like, and i can augment the demo code to exercise both?
(or we can go back to datascript, just lmk and i can update the PR)
yeah, it's fine I guess
merged
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.