figwheel-main 2025-02-11

I can now randomly get the tests to run in CI. I'm curious if it's related to the REPL not establishing a proper connection? For example, when you run figwheel-main in development and a browser is automatically opened a REPL connection sometimes doesn't get established right away and instead you have to refresh the browser tab a few times. If I wait some time I will eventually get an error. But this is not all the time.

Expected REPL Connections Evaporated!
No stacktrace available.
Execution error (ExceptionInfo) at cljs.repl/evaluate-form (repl.cljc:577).
Expected REPL Connections Evaporated

@tkjone first of all thanks for working on this with me. I'm going to dig into this if you are interested in continuing to follow along.

👍 1

Very much so. I'm kinda invested at this point lol

It would be nice to get info about what's happening when it's running in the container...

like the js console logging

👍 1

I can provide you with the Dockerfile I'm using with the intermittent issues as well if that helps (it's general aside from the code itself)

# Usage:
#   docker build --platform linux/amd64 --file -t app/fig-test .
#   docker run --rm -it --entrypoint bash 
#   docker exec -it  bash
#
#   sanity checks:
#     /usr/bin/google-chrome --no-sandbox --disable-gpu --disable-setuid-sandbox --headless=new --remote-debugging-port=9222 --disable-features=Dbus
#     java --version
#     clj --version
#     cat /etc/os-release

ARG NODE_VERSION=20
ARG CLJ_VERSION=1.12.0.1479

# ------------------------------------------------------------------------------
# Final Image
# ------------------------------------------------------------------------------
FROM eclipse-temurin:21

ARG NODE_VERSION
ARG CLJ_VERSION

# install node & system deps
RUN apt-get update \
    && curl -fsSL  | bash - \
    && apt-get install -y \
    nodejs \
    wget \
    gnupg \
    libgtk-3-0 \
    libdbus-glib-1-2 \
    libxt6 \
    bzip2 \
    file \
    --no-install-recommends

# install clojure cli
RUN curl -O "" \
    && chmod +x "linux-install-${CLJ_VERSION}.sh" \
    && bash "./linux-install-${CLJ_VERSION}.sh" \
    && rm -rf "linux-install-${CLJ_VERSION}.sh" \
    && clojure --version

# install chrome
RUN wget --no-verbose -O /usr/src/google-chrome-stable_current_amd64.deb 
RUN apt-get update
RUN apt-get install -f -y /usr/src/google-chrome-stable_current_amd64.deb

WORKDIR ${APP_DIR}

# cache deps - js
WORKDIR /app
COPY ./package.json ./package.json
RUN npm install

# cache deps - cljs
COPY ./deps.edn ./deps.edn
RUN clojure -P -M:test

# copy src code
COPY ./src ./src

> like the js console logging Which logging do you want to see? the environment.log?

committing a change to get logging streaming to the repl...

OK try this, figwheel options :open-url-wait-ms and give it a high number like 5000 or even 10000 to see if that helps

It just seems like there is a really strange delay in the websocket start. Like it's blocking on something.

@tkjone ok I just deployed another SNAPSHOT and :open-url-wait-ms should work in conjunction with the :connect-url to get your tests running consistently...

but there is definitely a big delay in the websocket on connect that is buggering things up, so I'm either going to have really dig in to see what's causing it or revert to code that was working before.

👍 1

Trying now

To confirm, the SNAPSHOT is 0.2.21-SNAPSHOT still, yes?

Out of curiosity, which repo was this change made in? I'm looking through the commits of figwheel-main and figwheel-repl and I don't see a new commit?

yep that is the snapshot

and yes I didn't push the commit to github yet but it should be in the SNAPSHOT

👍 1

So I guess nothing changed.

kk. Then 5000 and 10000 waits didn't seem to help 😞

just to clarify you checked :pprint-config to make sure your options were getting picked up correctly. And if so and your are using long-polling then something else is the problem

config with :pprint-config set:

---------------------- Figwheel options ----------------------
{:figwheel.main/build-inputs ["test"],
 :pprint-config true,
 :ring-server-options {:port 9504},
 :auto-bundle :webpack,
 :mode :repl,
 :connect-url
 "http://[[config-hostname]]:[[server-port]]/figwheel-connect",
 :launch-js
 ["/opt/google/chrome/chrome"
  "--no-sandbox"
  "--disable-dev-shm-usage"
  "--disable-gpu"
  "--headless"
  "--remote-debugging-port=9222"
  "--repl"
  :open-url],
 :open-url-wait-ms 10000,
 :watch-dirs ("test"),
 :final-output-to "target/public/cljs-out/main_bundle.js",
 :ring-stack-options
 #:figwheel.server.ring{:dev
                        #:figwheel.server.ring{:system-app-handler
                                               #object[figwheel.main$default_main$fn__9237 0x251ad030 "figwheel.main$default_main$fn__9237@251ad030"]}}}
---------------------- Compiler options ----------------------

{:infer-externs true,
 :output-dir "target/public/cljs-out",
 :closure-defines
 {goog/DEBUG false,
  app.web.core/env "production",
  figwheel.repl/connect-url
  ""},
 :aot-cache false,
 :preloads
 [figwheel.core
  figwheel.main
  figwheel.repl.preload
  devtools.preload
  figwheel.main.system-exit],
 :output-to "target/public/cljs-out/main.js",
 :asset-path "/cljs-out",
 :bundle-cmd
 {:none
  [:npx-cmd
   "webpack"
   "--mode=development"
   "--entry"
   :output-to
   "--output-path"
   :final-output-dir
   "--output-filename"
   :final-output-filename],
  :default
  [:npx-cmd
   "webpack"
   "--mode=production"
   "--entry"
   :output-to
   "--output-path"
   :final-output-dir
   "--output-filename"
   :final-output-filename]},
 :repl-requires
 ([figwheel.repl :refer-macros [conns focus]]
  [figwheel.main
   :refer-macros
   [stop-builds start-builds build-once reset clean status]]
  [cljs.pprint :refer [pprint] :refer-macros [pp]]
  [cljs.repl :refer-macros [source doc find-doc apropos dir pst]]),
 :target :bundle,
 :main app.test-runner-ci}
and this is the cljs.edn file
^{:auto-bundle         :webpack
  :ring-server-options {:port 9504}
  :open-url-wait-ms    10000
  :connect-url         "http://[[config-hostname]]:[[server-port]]/figwheel-connect"}
{:main            app.test-runner-ci
 :infer-externs   true
 :output-dir      "target/public/cljs-out"
 :output-to       "target/public/cljs-out/main.js"
 :closure-defines {goog/DEBUG             false
                   app.web.core/env  "production"}}

That looks good, can't speak to your application but that looks good. OK so one more thing to try, set :client-log-level :finest which should now stream some console.logs back to you, if it even connects

👍 1

As it stands: • tests run locally (M series mac): 100% • tests run in linux docker container (cited above - Ubuntu distro): 70% • tests run in linux Github Actions Env: 0% What threw me is that prior to the ring changes they ran in GHA 100%

fun stuff.... well this is strange for sure... I'm going to have to hammock on this for a bit, but something is definitely up.

👍 1

OK so one more thing to try, set :client-log-level :finest which should now stream some console.logs back to you
This is interesting. I set it to :finest in fwo and nothing is streamed back 😮. Running this in my local env where the tests actually run

I'm assuming that its running locally and in your local containers. Also, it seems to be working for https://clojurians.slack.com/archives/CALJ3BFLP/p1739981329856999?thread_ts=1739853803.317139&cid=CALJ3BFLP

> I'm assuming that its running locally and in your local containers. Testing again now. It runs locally. It run intermittently in local containers.

I've added logs through the tests now. It seems that the test-runner "main script" never being run. Next step is start stripping away everything to see if the most simple thing will work (tried this a while back as well, but no different in behavior at that time)

you could just greenfield a figwheel-main-template to see if that works....

👍 1

Ugh. I might have spoken too soon. I have to perform some other tests to confirm, but the issue still seems to be present

oh really? Actually try the new SNAPSHOT I just deployed it, which removes my use of future which would could have a thread hanging things up

Still hanging 😞

well that's disappointing... it would really be nice to see what is going on here. Are the tests finishing but the process hanging?

I gotta dig into it more to see where they are at. Github Actions is very difficult to see what's going on inside them

OK I have another SNAPSHOT for you to try. I think I finally found a problem. You should again get rid of the :connect-url and hopefully your tests will work like before

Very exciting! I'll jump on this in 30min

They are fixed!

Thanks @bhauman 🎉

👏 1

Thanks for working through this with me. I probably could have used more hammock time and less implementing time but there we are.

Thanks for this I'll give it. alook

@bhauman I setup a minimal repro repo. here https://github.com/athomasoriginal/test-figwheel-headless-tests which should illustrate what I'm seeing.

I added repro steps in the README

Acutally this means you probably didn't get rid of the :connect-url which will revert back to websocket use.

👍 1