Fork me on GitHub
#clojurescript
<
2024-05-20
>
Anton Shastun10:05:23

Hello! Do any one know how to build shadow-cljs sub project from other dir? I have clj project in one dir and cljs in other, and i what to run build from build.clj Thanks!

p-himik11:05:26

I would just shell out with a change of directory.

👍 1
thheller15:05:43

agreed. assuming build.clj is a tools.build type setup, then its best to shell out.

Anton Shastun15:05:13

@U05224H0W do you mean

(shell "cd ../subproject && npx shadow-cljs release app")
from build.clj?

thheller16:05:16

not a clue what this looks like in tools.build. never used it for anything yet. I think it has some helpers for this

thheller16:05:42

one that would let you specify the working dir I'd presume, so there would be no need for the cd + &&

thheller16:05:58

if you sub project is also using deps.edn then java-command would also work

Anton Shastun16:05:16

as i undertand build.api/process just running shell cmd as java.shell i have try

(sh "sh" "-c" "cd ../subproject && npx shadow-cljs release app")
and it works

thheller16:05:40

I'd assume process looks something like this and less sketchy IMHO

(b/process
  {:command-args ["npx" "shadow-cljs" "release" "app"]
   :dir "../subproject"})

👍 1
thheller16:05:19

but again .. never used it. so if sh works then just use that 😛

Anton Shastun16:05:45

that also works )

Anton Shastun16:05:46

@U05224H0W is it any way to do some thing like?

(binding [shadow.api/project-root "../"]
  (shadow.api/release :app))

p-himik17:05:53

Even if there was, you shouldn't do it since it'd require using the same classpath for build.clj and for shadow-cljs.

Rambabu Patina17:05:53

Hello, I am facing one issue while developing a rest endpoint using reitit.ring and it is throwing an error "`Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client`". Here is the code,

Endpoint:
(ring/ring-handler
      (ring/router
        [["/api"
            ["/globalconfig"
              {:get handlers/config-handler}]]]))

Handler:
(defn config-handler
  [{:keys [body]
    :as request}
    respond _]
  (p/let [config-data (helper/get-app-property {:property-id "app-key"})] ;;Till this point working fine I see config details in the logs
    (respond {:status 200 :body config-data})))
It is not retuning the actual configuration to the client and throwing above error in server. Could you please help me to fix the issue. Looking forward for your response. Thanks in Advance!

p-himik17:05:49

What is the stacktrace of the error? What is the web server? Do you have any middleware?

Rambabu Patina17:05:37

Here is the stacktrace:

>  Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
>      at new NodeError (node:internal/errors:405:5)
>      at ServerResponse.setHeader (node:_http_outgoing:648:11)
>      at ServerResponse.writeHead (node:_http_server:381:21)
>      at /Users/xxxxx/sde/development/xxxxx-xxxx-xxxx/.shadow-cljs/builds/functions/dev/out/cljs-runtime/macchiato/http.cljs:110:5
>      at /Users/xxxxxx/sde/development/xxxxxx-xxxxx-xxxxx/.shadow-cljs/builds/functions/dev/out/cljs-runtime/macchiato/http.cljs:106:10
>      at respond_SINGLEQUOTE_ (/Users/xxxxxx/sde/development/xxxxxx-xxxxx-xxxxx/.shadow-cljs/builds/functions/dev/out/cljs-runtime/reitit/ring.cljc:119:43)
>      at /Users/xxxxxx/sde/development/xxxxxx-xxxxx-xxxxx/.shadow-cljs/builds/functions/dev/out/cljs-runtime/xxxxx_xxxxx/server/handlers.cljs:265:6
>      at /Users/xxxxxx/sde/development/xxxxxx-xxxxx-xxxxx/.shadow-cljs/builds/functions/dev/out/cljs-runtime/xxxxxx_xxxxx.server.handlers.js:185:3
>      at /Users/xxxxxx/sde/development/xxxxx-xxxxx-xxxxx/.shadow-cljs/builds/functions/dev/out/cljs-runtime/promesa/impl.cljc:86:30
>      at processTicksAndRejections (node:internal/process/task_queues:95:5)
i  Request to function failed: Error: socket hang up

Rambabu Patina17:05:49

We have middlewares but for this endpoint I did not add anything

Rambabu Patina17:05:52

Currently running the app locally with firebase emulators to develop in local first

Rambabu Patina08:05:15

@U2FRKM4TW Could you please suggest

p-himik17:05:17

Sounds like a Macchiato problem. Maybe this if you have an old version, maybe something else: https://github.com/macchiato-framework/macchiato-core/pull/39

Rambabu Patina06:05:27

Thanks @U2FRKM4TW for your help. There is an issue in body actually which fixed the issue (respond {:status 200 :body config-data})