This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-10-10
Channels
- # announcements (3)
- # babashka (3)
- # beginners (83)
- # calva (1)
- # cider (19)
- # clojure (131)
- # clojure-austin (4)
- # clojure-dev (3)
- # clojure-europe (49)
- # clojure-greece (2)
- # clojure-italy (8)
- # clojure-losangeles (18)
- # clojure-nl (14)
- # clojure-poland (1)
- # clojure-uk (65)
- # clojurescript (28)
- # core-async (7)
- # core-logic (3)
- # cursive (2)
- # data-science (1)
- # datomic (98)
- # defnpodcast (1)
- # figwheel-main (6)
- # fulcro (95)
- # graphql (5)
- # hoplon (7)
- # kaocha (1)
- # lein-figwheel (6)
- # luminus (1)
- # nyc (1)
- # off-topic (21)
- # pedestal (1)
- # quil (8)
- # re-frame (15)
- # reagent (106)
- # reitit (15)
- # shadow-cljs (158)
- # sim-testing (1)
- # spacemacs (17)
- # sql (25)
I've read the relevant bits of the user guide, but I don't really understand how to set up CSS reloading. My CSS file is at resources/public/css/main.css
, and my HTTP server serves it at /assets/css/main.css
. What do I need to set as the values of :watch-dir
and :watch-path
so that CSS reloading works?
Hi guys, I'm experiencing constantly the REPL server crash after a while
$ shadow-cljs watch app
shadow-cljs - config: /path/to/shadow-cljs.edn cli version: 2.8.61 node: v10.16.3
..... (after a while ) ....
[:app] Compiling ...
[:app] Build completed. (68 files, 1 compiled, 0 warnings, 0.04s)
shutting down ...
Worker shutdown.
Exception in thread "async-dispatch-7" java.lang.Error: java.net.SocketException: Socket closed
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1155)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.SocketException: Socket closed
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:118)
at java.net.SocketOutputStream.write(SocketOutputStream.java:155)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at nrepl.transport$bencode$fn__5929.invoke(transport.clj:116)
at nrepl.transport.FnTransport.send(transport.clj:41)
at nrepl.middleware.print$send_nonstreamed.invokeStatic(print.clj:159)
at nrepl.middleware.print$send_nonstreamed.invoke(print.clj:138)
at nrepl.middleware.print$printing_transport$reify__6306.send(print.clj:174)
at nrepl.middleware.caught$caught_transport$reify__6341.send(caught.clj:58)
at shadow.cljs.devtools.server.nrepl_impl$send.invokeStatic(nrepl_impl.clj:32)
at shadow.cljs.devtools.server.nrepl_impl$send.invoke(nrepl_impl.clj:19)
at shadow.cljs.devtools.server.nrepl_impl$worker_exit.invokeStatic(nrepl_impl.clj:49)
at shadow.cljs.devtools.server.nrepl_impl$worker_exit.invoke(nrepl_impl.clj:45)
at shadow.cljs.devtools.server.nrepl_impl$repl_init$fn__6916$state_machine__2842__auto____6941$fn__6943.invoke(nrepl_impl.clj:207)
at shadow.cljs.devtools.server.nrepl_impl$repl_init$fn__6916$state_machine__2842__auto____6941.invoke(nrepl_impl.clj:205)
at clojure.core.async.impl.ioc_macros$run_state_machine.invokeStatic(ioc_macros.clj:973)
at clojure.core.async.impl.ioc_macros$run_state_machine.invoke(ioc_macros.clj:972)
at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:977)
at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:975)
at clojure.core.async.impl.ioc_macros$take_BANG_$fn__2860.invoke(ioc_macros.clj:986)
at clojure.core.async.impl.channels.ManyToManyChannel$fn__655.invoke(channels.clj:265)
at clojure.lang.AFn.run(AFn.java:22)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
... 2 more
I got this for both :target :node-script
and :target :browser
. The shadow-cljs watch app
command is still running there though.
@wxitb2017 are you on OSX by any chance?
hmm yeah multiple people have been reporting this on OSX. it seems like something in the OS is starting to kill the shadow-cljs process when it reaches a certain memory usage
you can set :jvm-opts ["-Xmx1G"]
to limit it to 1gig of RAM (either in shadow-cljs.edn
or project.clj
in case you use lein)
ah, so the "shadow-cljs watch app" is a node process, which wraps the java process, right?
Ok, I attached a cursive debugger to the shadow-cljs java process and added a breakpoint, and it seems it's the health check from java->npm that leads the worker shutdown
can you turn on :log {:level :debug}
in shadow-cljs.edn
? the exception should be logged and might provide a clue?
the way this works is the node
process opens a TCP socket that the JVM process frequently connects to and checks if its still there
otherwise there were problem where the JVM process kept running when the node process was killed
btw I just changed the interval from 1s to 10s, and installed it by lein install
. So far so good for the last 20minutes.
I suggest 1) increase the interval, at least to e.g. 3s. 2) maybe only abort when failed 3 times in succession
thanks for digging into this. I'd still rather find out what is happening in the first place before trying to work around it though. a local TCP connect every second shouldn't be a problem. maybe I'll change it to a heartbeat style and just leave the connection open for longer
you can also assign less or more RAM. depends on how much your machine has I guess. would be interesting to find out when it starts crashing 😛
sure, I already applied the 1G limit and restarted it. Would report back if that helps. Thx a lot!
I tried "-Xmx1G" and "-Xms2G -Xmx5G" etc., none of them made any difference 😞 @thheller
could you try running some of the commands listed here? https://stackoverflow.com/questions/726690/what-killed-my-process-and-why
I'm using a mac, with 32GB RAM 🙂 And btw according to my traceback shared earlier, I doubt it's some code in the shadow-cljs/nrepl that crashed the java process http://paste.openstack.org/raw/783109/ (pay attention to Exception in thread "async-dispatch-7" java.lang.Error: java.net.SocketException: Socket closed
)
Does anyone know if there are docs for how to build the Shadow CLJS client-side code without optimizations? I’ve been trying to troubleshoot CSS reloading and was hoping to step through this code in the browser:
- Source: https://github.com/thheller/shadow-cljs/blob/2.8.51/src/main/shadow/cljs/devtools/client/browser.cljs#L166-L199 which ends
- In our app: /<CLOSURE_BASE_PATH>/shadow.cljs.devtools.client.browser.js
My plan was to:
- Clone the repo
- Change the optimizations (???)
- Run the “build all” script
- Use npm link
to use the <repoDir>/packages/shadow-cljs and shadow-cljs-jar packages in our app
- Rebuild our app and step through the less minified code 🤞
Does that sound like it’d work?
@sean.poulter I'm confused. there are no optimizations applied in watch
or compile
builds? only release
builds and those won't contains the client/browser.cljs
?
It’s a watch
build on the app end, yea.
I guess that means it’d have to be modified on our end. :thinking_face:
you can just take the browser.cljs
and add it into one of your :source-paths
if you want to make modifications
I’ve got that far. It’s minified and a bit confusing without a source map.
Thanks for correcting me on that, yes.
Ah. We must have source maps off. It’s a bit different on our end and just the compiled JS under (no domain)
:
Thanks for your patience with this. I’ve dropped into the Clojure world from JavaScript. 😓
@sean.poulter there isn't much to CSS reloading, it is watching a directory via either :watch-dir
or the http root. lets say public
. You have a public/css/foo.css
. it will attempt to reload /css/foo.css
. you can specify :watch-path "/x"
which would make it try to reload /x/css/foo.css
So the watch-path is prepended to the link href?
it is prepending :watch-path
to the PATH of the .css
file it is trying to reload yes
but if the <link
doesn't already use that path, it won't reload because it will think it is a different file
I'll give that a try. We're using a proxy to use local code against a prod backend which is at server.localhost:port/extra-path/css/foo.css.
I gave it a try and it didn't work, so I've gone down a rabbit hole trying to figure out why.
("I gave it a try" meaning, trying to follow the docs with the watch dir and watch path not working.)
The JS hot reloads and its served from the same folder.
It's honestly quite confusing to me.
It's a <link href="/css/foo.css"/>
.
Should be! Oooh. :thinking_face:
It's loading our local CSS, just not reloading it.
Yea. So all of this is why I was trying to figure out how to step through where it's deciding it's not working.
Thanks so much for talking it through! I'll go dig into the watch-path and also figure out my source maps. :)
but to repeat: you have <link href="/css/foo.css"/>
. that means it will only reload files that have :watch-dir
+ /css/foo.css
, so if :watch-dir "public"
then public/css/foo.css
check the browser console if an actual request is triggered. you might just get the old css back from the server?
I'll report back when I figure it out. It worked beautify when I configured the example in the README to build to dist. It doesn't make the request or log to the console. From the compiled code it looked like it was a path problem.
Just to follow-up:
1. Thank you again! 👏
2. Watching the messages on the web socket helped.
3. The CSS reloading works great just with :watch-path "/foo/bar"
. I think my trouble was caused by missing the leading /
on the :watch-path
. :man-facepalming:
4. It also needed to have :watch-dir "dist"
’cause we weren’t using the default public
folder.
@thheller is there a way to figure out how a particular thing is getting into the output? I’m working on native in a shared source project and react-dom keeps leaking in…really painful figuring out how
@tony.kay the web UI has a thing. after you hit comile or watch there is a "Build Namespaces" select box
@thheller trying to import a custom class, getting a type error TypeError: Cannot read property 'prototype' of undefined
const { AuthenticationService, JWTStrategy } = require('@feathersjs/authentication');
const { OAuthStrategy } = require('@feathersjs/authentication-oauth');
class AzureB2CStrategy extends OAuthStrategy {
constructor(...args) {super(...args);}
authenticate({error}, params) {
super.authenticate(error, params);
}
}
module.exports = AzureB2CStrategy
Then in my require ["./azureb2c.js" :as AzureB2CStrategy]
Yeah I was able to confirm this works ["@feathersjs/authentication-oauth" :as auth]
then (def OAuthStrategy (obj/get auth "OAuthStrategy"))
nodejs
I’ll try with that again, I was using :es6
yeah the stack trace is pointing to the super
in constructor
where should I look?
no cljs-runtime folder
I could be on an old version
ah yes I did
oh ok
kk i’ll try that
shadow$provide.module$degree9$auth$azureb2c = function(
global,
process,
require,
module,
exports,
shadow$shims
) {
require("shadow.js.shim.module$$feathersjs$authentication");
var OAuthStrategy = require("shadow.js.shim.module$$feathersjs$authentication_oauth")
.OAuthStrategy;
global = function(args) {
for (
var $jscomp$restParams = [], $jscomp$restIndex = 0;
$jscomp$restIndex < arguments.length;
++$jscomp$restIndex
)
$jscomp$restParams[$jscomp$restIndex - 0] = arguments[$jscomp$restIndex];
return (
OAuthStrategy.apply(
this,
$jscomp.arrayFromIterable($jscomp$restParams)
) || this
);
};
$jscomp.inherits(global, OAuthStrategy);
global.prototype.authenticate = function($jscomp$destructuring$var2, params) {
OAuthStrategy.prototype.authenticate.call(
this,
$jscomp$destructuring$var2.error,
params
);
};
module.exports = global;
};
thats the compiled code, definitely polyfilled which it shouldn't do when using :es6+
dunno which JS version added ...args
, it node supports that natively bump it to whatever language version that is 😛
@thheller this is with es-next
as output-feature-set
Same type error
So it seems that any use of super
in my js files fails
Ok so it looks like the files are in TypeScript that I am trying to require via the JS, npm has the compiled js tho
@flyboarder I think you are just not doing the config properly? when I set :es6 I get
shadow$provide.module$demo$test = function(global, require, module, exports) {
require("shadow.js.shim.module$$feathersjs$authentication");
({
OAuthStrategy: global
} = require("shadow.js.shim.module$$feathersjs$authentication_oauth"));
class AzureB2CStrategy extends global {
constructor(...args) {
super(...args);
}
authenticate({ error }, params) {
super.authenticate(error, params);
}
}
module.exports = AzureB2CStrategy;
};
//# sourceMappingURL=module$demo$test.js.map
dunno how to check if that actually works but you are definitely not doing the config correctly if you still gets the transpiled version afterwards