Fork me on GitHub
#shadow-cljs
<
2021-04-19
>
Volodymyr Huzar09:04:00

I have a problem with starting shadow-cljs server on my Jenkins Alpine Linux machine using shadow-cljs start After long time I’m getting

shadow-cljs - server starting "a lot of dots and" `Cannot contact jenkins_cluster: hudson.remoting.RequestAbortedException: java.nio.channels.ClosedChannelException` error.
It could be some policy of our Jenkins which doesn’t allow that but I cannot find any information which I can pass to our DevOps to investigate that. Is the some way to get more details what is going on under the hood of this command? Or maybe there is a way to enable some logs (`-v` and --debug shows nothing)?

Volodymyr Huzar10:04:44

The same is going one when I try to run shadow-cljs start on Docker image https://github.com/theasp/docker-clojurescript-nodejs locally. You can reproduce it from your project directory using

docker run --rm -v ${PWD}:/home/my-project -w="/home/my-project" theasp/clojurescript-nodejs:latest npx shadow-cljs start

thheller14:04:22

why are you using start in a CI environment?

Volodymyr Huzar14:04:41

@thheller I would like to use https://github.com/lambdaisland/kaocha-cljs2 to run tests and I need somehow to serve the compiled tests with shadow-cljs, so I have decided to use shadow-cljs server for that. I am not sure if it is the best choice. I would appreciate a better advice on that if you have

thheller14:04:13

hmm I don't know anything about kaocha or how it runs tests unfortunately

Volodymyr Huzar15:04:21

Actually what I need is to serve the complied directory with lambdaisland.chui.remote to be preloaded. And shadow-cljs server looks ideal. I could try to look for another way to achieve the same. But do you have any idea why it doesn’t work on Docker? Is it expected or can I log the issue in GitHub for that?

thheller15:04:21

I don't have a clue why it wouldn't work. maybe the logfiles created in the .shadow-cljs/ dir provide some clues? I'm not capable of debugging docker issues. if server works fine I'd assume start to work as well since the only thing it does is detach to process into the background.

Volodymyr Huzar15:04:33

let me actually check if shadow-cljs server works inside Docker. I haven’t checked it separately

Volodymyr Huzar16:04:02

@thheller when I am using shadow-cljs server with local docker I get a project specific error (out of scope for my question). But it seems shadow-cljs start hanging when errors occur, is it possible?

thheller16:04:30

how does it fail? could certainly affect start yes

Volodymyr Huzar16:04:25

shadow-cljs server failed (actually process just ends) during fetching lein private dependencies because of luck of permissions. During shadow-cljs start it just shows dots

thheller16:04:05

yeah with start all logging goes into the log files in .shadow-cljs/server.stdout.log or server.stderr.log

Volodymyr Huzar12:04:28

@thheller thanks for you advices, they helped me to find root cause of the problem. I will create an issue in GitHub for use case that start is hanging when error occurs during start up if you don’t mind. My root issue on Jenkins was that jks ssl certificate which we use for local environment was not committed and I still not sure is it a good idea to commit it. Is it possible somehow to force shadow-cljs to ignore ssl certificate if it is not found instead of throwing exception?

thheller12:04:43

if the cert is not found ssl won't work? or do you not need that to work?

Volodymyr Huzar12:04:59

I don’t need that to work. I need SSL for local server but not when I run tests

thheller12:04:22

hmm yeah I guess there should be an option to disable that but for CI you could just write a simple script that just deletes the :ssl config from shadow-cljs.edn before actually starting it

Volodymyr Huzar12:04:59

Option will be better, but I try to write something in meanwhile

thheller12:04:20

(require '[ :as io])
(require '[clojure.edn :as edn])
(let [file (io/file "shadow-cljs.edn")]
  (-> (slurp file)
      (edn/read-string)
      (dissoc :ssl)
      (as-> config
        (spit file (pr-str config)))))

thheller12:04:42

if you have clojure installed on the CI system you can just put that into a script file and run it with that

thheller12:04:47

or use something like babashka

Volodymyr Huzar12:04:03

thanks a lot. I’ll try

thheller12:04:07

feel free to open issues about this. can't get to it now but maybe later

ingesol10:04:50

While setting up :js-provider :external, I have found that it only works with ["react" as react] style requires. Meaning that both the string-style and the alias is required in order for the corresponding js require to be generated. Is this a known issue/by design? This could be very tricky for others to figure out. The string syntax is fine, when documented, but the required alias is more of a pitfall.

thheller14:04:03

@ingesol that is a bug yes

ingesol14:04:06

@thheller Ok, I’ll retest to verify the pattern and post a bug

witek15:04:59

Hi. I am building with :target :node-library and I would like to use the fetch api. But (js/fetch ...) fails with fetch is not definded and requiring ["node-fetch"] fails with symbol module$shadow_js_shim_module$node_fetch already provided by [:shadow.build.js-support/require "node.fetch"], conflict with [:shadow.build.js-support/require "node-fetch"]. Any suggestions how to access the fetch function? Thank you.

thheller16:04:55

looks like you have a node.fetch and a node-fetch? they clash, stick to one I guess?

witek16:04:49

What do you mean by "you have"? In my own namespaces I don't use any of these. But I would like to and I can not fugure out how to require it.

thheller16:04:02

you said "requiring node-fetch failed". try node.fetch

thheller16:04:31

which shadow-cljs version do you use? I thought these kinds of clashes were fixed?

witek16:04:41

I am on the latest version. Requiring [node.fetch :as nf] errors in the compiler with he required namespace "node.fetch" is not available. Requiring ["node.fetch" :as nf] passes the compiler, but errors at runtime when loading with Error: Cannot find module 'node.fetch'. 😞

thheller16:04:01

I'm confused then. something else appears to be using it?

thheller16:04:17

so even if you fix your end it still won't run since that uses it?

witek16:04:11

Everything runs fine. Until I require anything of it.

thheller16:04:00

I'm entirely confused. WHERE does the "node.fetch" come from? if you ONLY have "node-fetch" that should be totally fine but having that as well as "node.fetch" will not work

thheller16:04:11

as the error tells you SOMETHING required "node.fetch"

witek16:04:18

I have some dependencies. Like firebase-admin and firebase-functions. Perhaps it comes from there.

thheller16:04:36

not if you are using :node-library, then shadow-cljs will not process any npm dependencies at all. some CLJS code must be requiring that

witek16:04:06

Ok, I will check. Or narrow down my scope. Thank you very much for your time!

thheller17:04:37

also verify which shadow-cljs version you are using. I thought I fixed this particular issue.

thheller17:04:10

the problem is that node-fetch AND node.fetch both munge into the module$shadow_js_shim_module$node_fetch pseudo-namespace and they need to be unique

thheller17:04:04

although I don't understand how you get that name to be honest. that should be shadow.js.shim.module$node_fetch. might be something weird in your setup, can't say

witek17:04:56

For the record. What I forgot to mention 😞 is that my compiled code is not executed directly - instead the Firebase Cloud Functions Emulator loads it. I added "node-fetch" to my package.json and now requireing "node-fetch" works.