Fork me on GitHub
#scittle
<
2023-11-19
>
mynomoto18:11:35

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)
--------------------------------------------------------------------------------

borkdude18:11:43

you probably need to bump promesa

mynomoto18:11:52

Ok, trying again.

mynomoto18:11:07

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

mynomoto18:11:21

On the browser console now.

borkdude18:11:20

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

mynomoto19:11:13

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

mynomoto19:11:39

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.

borkdude19:11:14

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

borkdude19:11:45

looks correct to me

borkdude19:11:28

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

borkdude19:11:43

something like that probably

borkdude19:11:00

perhaps you can save the sources in another mutable thing

borkdude19:11:25

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

mynomoto19:11:08

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

borkdude19:11:52

with sources I mean the sources from the script tags

borkdude19:11:42

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

mynomoto19:11:22

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

borkdude19:11:15

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

borkdude19:11:58

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

mynomoto19:11:51

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.

mynomoto13:11:01

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.

borkdude13:11:09

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

borkdude13:11:47

h/text is probably fine without that

borkdude13:11:51

but could be an edge case there

mynomoto13:11:59

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

mynomoto13:11:30

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

borkdude13:11:46

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

borkdude13:11:12

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

mynomoto13:11:15

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

borkdude13:11:21

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

borkdude13:11:49

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

borkdude13:11:59

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

borkdude13:11:13

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

mynomoto13:11:46

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.

borkdude13:11:56

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

borkdude13:11:18

it does work for some other example in your case?

mynomoto13:11:33

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

borkdude13:11:51

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

mynomoto13:11:46

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

borkdude13:11:43

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.

borkdude13:11:40

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

mynomoto13:11:51

Ok, will do.

mynomoto13:11:11

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. 😅

alandipert17:11:06

wow thanks you guys for working through this, extremely excited

mynomoto17:11:11

@U04VC31U8 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

thanks3 1
borkdude17:11:46

merged

🎉 1
alandipert18:11:38

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

alandipert18:11:03

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

borkdude18:11:25

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

👍 1
borkdude18:11:16

I guess we can leave datascript in as well?

alandipert18:11:56

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

alandipert18:11:17

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

borkdude19:11:03

yeah, it's fine I guess

mynomoto18:11:22

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.