etaoin

shem 2023-03-08T14:19:10.724179Z

i have a babashka/etaoin script that stopped working a couple of weeks ago. i've tried with chrome and firefox, also with :path-browser defined but it quits with β€œclojure.lang.ExceptionInfo: gave up trying to launch :chrome after 1 tries [at etaoin/api.clj:3504:9]”. i've tried maxing out logging but it won't elaborate on the failure. i get the same error in a minimal repl session. this is on arch linux, babashka v1.2.174, etaoin 1.0.39

☝️ 1
shem 2023-03-13T08:13:50.211439Z

@lee it's not acute, headless mode is fine

πŸ‘ 1
lread 2023-03-08T14:26:18.403389Z

Hi @shem, can you extract a minimal example so we can try to reproduce the issue? One thing that trips me up sometimes is a WebDriver/browser version mismatch. Chrome might get update on my system, but then I also need to update chromedriver.

shem 2023-03-08T14:28:33.753889Z

user=> (require '[babashka.deps :as deps])
nil
user=> (deps/add-deps '{:deps {etaoin/etaoin {:mvn/version "1.0.39"}}})
nil
user=> (require '[etaoin.api :as e])
nil
user=> (def driver (e/chrome))
2023-03-08T14:03:12.293Z UnknownHost DEBUG [etaoin.api:?] - Created driver: chrome 127.0.0.1:45035
2023-03-08T14:03:17.296Z UnknownHost DEBUG [etaoin.api:?] - Starting process: chromedriver --port=45035
2023-03-08T14:03:17.300Z UnknownHost DEBUG [etaoin.api:?] - Waiting until 127.0.0.1:45035 is running
clojure.lang.ExceptionInfo: gave up trying to launch :chrome after 1 tries [at etaoin/api.clj:3504:9]
user=> (def driver (e/chrome {:headless false :path-browser "/opt/google/chrome-beta/chrome"
                :args "--ozone-platform-hint=auto" :log-level :all :driver-log-level "DEBUG"}))
2023-03-08T14:07:13.899Z UnknownHost DEBUG [etaoin.api:?] - Created driver: chrome 127.0.0.1:43547
2023-03-08T14:07:18.900Z UnknownHost DEBUG [etaoin.api:?] - Starting process: chromedriver --port=43547 --log-level=DEBUG
2023-03-08T14:07:18.904Z UnknownHost DEBUG [etaoin.api:?] - Waiting until 127.0.0.1:43547 is running
clojure.lang.ExceptionInfo: gave up trying to launch :chrome after 1 tries [at etaoin/api.clj:3504:9]

shem 2023-03-08T14:29:25.721389Z

i have checked that the webdriver version matches browser version

lread 2023-03-08T14:39:14.421159Z

cool, thanks, I'll give this a whirl sometime soon. If you have a moment can you clone https://github.com/clj-commons/etaoin and then from etaoin run bb tools-versions for me? This is a etaoin developer sanity task, but can help in troubleshooting situations like this one.

shem 2023-03-08T14:39:27.549959Z

i just tried in a fresh jvm clojure project and that also dies with {:message "unknown error: Chrome failed to start: exited abnormally.\n (unknown error: DevToolsActivePort file doesn't exist)\n (The process started from chrome location /opt/google/chrome-beta/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)\n (Driver info: chromedriver=111.0.5563.41 (976ef12907ef9b413c2d929c043307b415d27b9e-refs/branch-heads/5563@{#737}),platform=Linux 6.2.2-arch1-1 x86_64)"}},

shem 2023-03-08T14:41:16.195459Z

|-------------------+-----------------------------------------------------------------------------------------------------+-----------------------|
|        Name       |                                               Version                                               |          Path         |
|-------------------+-----------------------------------------------------------------------------------------------------+-----------------------|
| Java              | openjdk version "11.0.18" 2023-01-17                                                                | /usr/bin/java         |
|                   | OpenJDK Runtime Environment (build 11.0.18+10)                                                      |                       |
|                   | OpenJDK 64-Bit Server VM (build 11.0.18+10, mixed mode)                                             |                       |
| Babashka          | babashka v1.2.174                                                                                   | /usr/bin/bb           |
| Image Magick      | Version: ImageMagick 7.1.0-62 Q16-HDRI x86_64 20885                          | /usr/bin/identify     |
| Chrome            | ** ERROR: bin not found: google-chrome **                                                           |                       |
| Chrome Webdriver  | ChromeDriver 111.0.5563.41 (976ef12907ef9b413c2d929c043307b415d27b9e-refs/branch-heads/5563@{#737}) | /usr/bin/chromedriver |
| Firefox           | Mozilla Firefox 110.0.1                                                                             | /usr/bin/firefox      |
| Firefox Webdriver | ** ERROR: bin not found: geckodriver **                                                             |                       |
|-------------------+-----------------------------------------------------------------------------------------------------+-----------------------|

shem 2023-03-08T14:43:09.367979Z

chrome is version 111.0.5563.64-1

lread 2023-03-08T14:44:03.232199Z

cool, thanks, I'll take a peek after I have some breakfast.

dysmento 2023-03-08T15:38:16.256169Z

I guess I came to the right place. I have this issue, too. Strange thing is that it's the same for firefox as well as chrome.

user=> (require '[etaoin.api :as e] '[etaoin.keys :as k])
nil
user=> (def driver (e/chrome))
2023-03-08T15:37:29.961Z L-SAN-220728-01 DEBUG [etaoin.api:?] - Created driver: chrome 127.0.0.1:57139
2023-03-08T15:37:29.997Z L-SAN-220728-01 DEBUG [etaoin.api:?] - Starting process: chromedriver --port=57139
2023-03-08T15:37:30.003Z L-SAN-220728-01 DEBUG [etaoin.api:?] - Waiting until 127.0.0.1:57139 is running
clojure.lang.ExceptionInfo: gave up trying to launch :chrome after 1 tries [at etaoin/api.clj:3504:9]
user=> (def driver (e/firefox))
2023-03-08T15:37:40.917Z L-SAN-220728-01 DEBUG [etaoin.api:?] - Created driver: firefox 127.0.0.1:57144
2023-03-08T15:37:40.918Z L-SAN-220728-01 DEBUG [etaoin.api:?] - Starting process: geckodriver --port 57144
2023-03-08T15:37:40.920Z L-SAN-220728-01 DEBUG [etaoin.api:?] - Waiting until 127.0.0.1:57144 is running
clojure.lang.ExceptionInfo: gave up trying to launch :firefox after 1 tries [at etaoin/api.clj:3504:9]

lread 2023-03-08T15:38:23.992149Z

ya, ok, can reproduce on Pop!_OS

lread 2023-03-08T15:39:00.427199Z

Interesting, huh? I'll try to figure out what is going on.

dysmento 2023-03-08T15:39:40.083969Z

Thank you! I'm happy to try any repro steps you want.

dysmento 2023-03-08T15:40:21.860249Z

|-------------------+-----------------------------------------------------------------------------------------------------+--------------------------------------------|
|        Name       |                                               Version                                               |                    Path                    |
|-------------------+-----------------------------------------------------------------------------------------------------+--------------------------------------------|
| Java              | openjdk version "17.0.6" 2023-01-17                                                                 | /Users/zachthomas/.asdf/shims/java         |
|                   | OpenJDK Runtime Environment Temurin-17.0.6+10 (build 17.0.6+10)                                     |                                            |
|                   | OpenJDK 64-Bit Server VM Temurin-17.0.6+10 (build 17.0.6+10, mixed mode)                            |                                            |
| Babashka          | babashka v1.2.174                                                                                   | /opt/homebrew/bin/bb                       |
| Image Magick      | Version: ImageMagick 7.1.0-62 Q16-HDRI aarch64 20885                         | /opt/homebrew/bin/magick                   |
| Chrome            | 111.0.5563.64                                                                                       | /Applications/Google             |
| Chrome Webdriver  | ChromeDriver 110.0.5481.77 (65ed616c6e8ee3fe0ad64fe83796c020644d42af-refs/branch-heads/5481@{#839}) | /opt/homebrew/bin/chromedriver             |
| Firefox           | 110.0.1                                                                                             | /Applications/Firefox.app                  |
| Firefox Webdriver | geckodriver 0.32.2                                                                                  | /opt/homebrew/bin/geckodriver              |
| Edge              | ** ERROR: mac app not found: Microsoft Edge **                                                      |                                            |
| Edge Webdriver    | ** ERROR: bin not found: msedgedriver **                                                            |                                            |
| Safari            | 16.3                                                                                                | /Applications/Safari.app                   |
| Safari Webdriver  | Included with Safari 16.3 (18614.4.6.1.6)                                                           | /System/Cryptexes/App/usr/bin/safaridriver |
|-------------------+-----------------------------------------------------------------------------------------------------+--------------------------------------------|

lread 2023-03-08T15:41:12.937169Z

@zach524 you seem to be running from babashka too, yeah?

dysmento 2023-03-08T15:41:43.892859Z

I am. Want me to use a plain ol' clojure repl?

borkdude 2023-03-08T15:42:42.816669Z

could it be the syntax change in babashka/process? should not have to matter but perhaps something broke

lread 2023-03-08T15:42:45.455189Z

Etaoin tests are failing for babashka, but seem to be passing for jvm.

lread 2023-03-08T15:42:59.175469Z

Good guess, @borkdude, probably.

borkdude 2023-03-08T15:42:59.353899Z

are you using the newest version of babashka/process in the JVM?

borkdude 2023-03-08T15:43:13.074399Z

if not, then that would explain the difference

borkdude 2023-03-08T15:43:46.295199Z

note: this should not have broken, but may accidentally have. I repent

lread 2023-03-08T15:43:48.319079Z

Right. Nope have not updated etaoin, still using 0.3.11.

borkdude 2023-03-08T15:44:00.568459Z

I'll take a look

lread 2023-03-08T15:44:56.805109Z

tx

borkdude 2023-03-08T15:48:43.532769Z

@lee I want to trigger the tests by pushing to a branch but that doesn't seem to work:

on:
  push:
    branches: ['master']
  pull_request:

borkdude 2023-03-08T15:48:55.026759Z

I dont' see why this isn't just [push, pull_request]

borkdude 2023-03-08T15:49:11.938999Z

I'll change it unless there's a good reason

lread 2023-03-08T15:51:06.988459Z

I think I didn't want to build branches that were not PRs... maybe? Go ahead and change if you like.

lread 2023-03-08T15:54:28.151919Z

I think that is still probably my preference, but if your workflow is to always run tests on branches, then that's ok.

borkdude 2023-03-08T16:00:58.584879Z

how else would I know if my commits are valid. I only create a PR once I'm done

lread 2023-03-08T16:01:13.766469Z

run tests locally?

borkdude 2023-03-08T16:01:16.798109Z

anyway, locally my tests seem to work

borkdude 2023-03-08T16:01:35.010569Z

we all know that "works on my machine" isn't the best way to test things

lread 2023-03-08T16:02:18.718299Z

do CI tests run for folks before they create PRs?

borkdude 2023-03-08T16:02:38.935119Z

yes, under their own account on Github

borkdude 2023-03-08T16:03:05.914489Z

thank god they do, else I'd have to look at some PR that failed every minute

borkdude 2023-03-08T16:03:13.812359Z

that gets old fast

borkdude 2023-03-08T16:03:37.946179Z

anyway, I want to solve the problem, not get into a bikeshed about who prefers what CI config

borkdude 2023-03-08T16:04:12.564009Z

and since locally they pass but on CI they fail, any help is welcome

lread 2023-03-08T16:04:15.154939Z

yeah, no, I'm not bikeshedding, just learning about something I might have misunderstood

lread 2023-03-08T16:04:46.715059Z

but we can talk about that separately

lread 2023-03-08T16:05:55.640499Z

etaoin bb test:bb fails for me locally

lread 2023-03-08T16:07:08.335489Z

I can poke around @borkdude, maybe easier for me because I have a local failure.

borkdude 2023-03-08T16:07:32.910589Z

$ bb test:bb
----- Error --------------------------------------------------------------------
Type:     java.lang.Exception
Message:  File does not exist: test:bb

lread 2023-03-08T16:08:23.148179Z

silly question: are you synched to master?

borkdude 2023-03-08T16:09:01.692369Z

maybe not...

borkdude 2023-03-08T16:09:33.625799Z

nope 25 commits behind πŸ˜† this day isn't going too well, damnit

lread 2023-03-08T16:10:23.510359Z

ha! that'll make the good days feel even better maybe...

borkdude 2023-03-08T16:10:33.202409Z

Failed to launch WebDriver binary `msedgedriver`.

borkdude 2023-03-08T16:10:42.933669Z

is there a way to limit to chromedriver?

dysmento 2023-03-08T16:10:55.499729Z

bb test:bb -b chrome

lread 2023-03-08T16:11:09.857479Z

Zach beat me to it.

borkdude 2023-03-08T16:11:47.638579Z

Most things run fine here, but:

ERROR in (test-screenshot-element) (/Users/borkdude/dev/etaoin/test/etaoin/api_test.clj:600)
chrome
expected: (valid-image? path)
  actual: clojure.lang.ExceptionInfo: please install image magick, we use it for screenshot image verification
{}

lread 2023-03-08T16:11:57.672419Z

Also bb tools-versions can help you sanity check your installs.

borkdude 2023-03-08T16:12:02.314309Z

brew install imagemagick

lread 2023-03-08T16:12:06.879299Z

yeah we use that in tests.

dysmento 2023-03-08T16:12:13.080829Z

Now you have time to get a coffee. πŸ˜„

borkdude 2023-03-08T16:12:51.867929Z

can I limit my test run to a failing test?

bb test:bb -b chrome ...?

borkdude 2023-03-08T16:13:02.791469Z

so I don't have to download half the internet

borkdude 2023-03-08T16:13:25.640029Z

ah there's an -h option, excellent

lread 2023-03-08T16:13:33.483989Z

yes

borkdude 2023-03-08T16:13:40.506889Z

but which test failed for you @lee?

borkdude 2023-03-08T16:14:49.243629Z

just give me one :)

lread 2023-03-08T16:15:18.990119Z

So... etaoin.api-test test setup it seems

borkdude 2023-03-08T16:15:48.353239Z

is that etaoin.api-test/test-setup ?

borkdude 2023-03-08T16:16:03.581029Z

Could not resolve var: etaoin.api-test/test-setup

borkdude 2023-03-08T16:17:09.772699Z

I don't know what you mean

lread 2023-03-08T16:17:19.801039Z

No the test fixture.

borkdude 2023-03-08T16:17:28.153249Z

I see

borkdude 2023-03-08T16:18:02.674339Z

$ bb test:bb -b chrome -v etaoin.api-test/test-visible

[ TASK test:bb -b chrome -v etaoin.api-test/test-visible ]-----------------------

[ Running tests ]----------------------------------------------------------------
suites: <none specified>
browsers: chrome
runner-args: [:vars etaoin.api-test/test-visible]

Running tests in #{"test"}

Testing etaoin.api-test
Testing with browsers: [:chrome]
:args ("chromedriver" "--port=51098") :type clojure.lang.LazySeq
=== test-visible [bb][chrome]

Ran 1 tests containing 4 assertions.
0 failures, 0 errors.

TASK test:bb done.

lread 2023-03-08T16:19:02.632179Z

❯ bb test:bb -b chrome -v etaoin.api-test/test-visible

[ TASK test:bb -b chrome -v etaoin.api-test/test-visible ]-----------------------

[ Running tests ]----------------------------------------------------------------
suites: <none specified>
browsers: chrome
runner-args: [:vars etaoin.api-test/test-visible]

Running tests in #{"test"}

Testing etaoin.api-test
Testing with browsers: [:chrome]
----- Error --------------------------------------------------------------------
Type:     clojure.lang.ExceptionInfo
Message:  gave up trying to launch :chrome after 1 tries
Data:     {}
Location: /home/lee/proj/oss/clj-commons/etaoin/src/etaoin/api.clj:3504:9

----- Context ------------------------------------------------------------------
3500:   (let [max-tries (inc webdriver-failed-launch-retries)]
3501:     (loop [try-num 1
3502:            ex nil]
3503:       (if (> try-num max-tries)
3504:         (throw (ex-info (format "gave up trying to launch %s after %d tries" (:type driver) max-tries) {} ex))
              ^--- gave up trying to launch :chrome after 1 tries
3505:         (do
3506:           (when ex
3507:             (log/warnf ex "unexpected exception occurred launching %s, try %d (of a max of %d)"
3508:                        (:type driver) (dec try-num) max-tries)
3509:             (Thread/sleep 100))

----- Stack trace --------------------------------------------------------------
etaoin.api/-run-driver                         - /home/lee/proj/oss/clj-commons/etaoin/src/etaoin/api.clj:3504:9
etaoin.api/-run-driver                         - /home/lee/proj/oss/clj-commons/etaoin/src/etaoin/api.clj:3460:1
etaoin.api/boot-driver                         - /home/lee/proj/oss/clj-commons/etaoin/src/etaoin/api.clj:3663:56
etaoin.api/boot-driver                         - /home/lee/proj/oss/clj-commons/etaoin/src/etaoin/api.clj:3640:1
etaoin.api-test                                - /home/lee/proj/oss/clj-commons/etaoin/test/etaoin/api_test.clj:71:3
... (run with --debug to see elided elements)
cognitect.test-runner.api/do-test              - /home/lee/.gitlibs/libs/io.github.cognitect-labs/test-runner/dfb30dd6605cb6c0efc275e1df1736f6e90d4d73/src/cognitect/test_runner/api.clj:6:1
cognitect.test-runner.api                      - /home/lee/.gitlibs/libs/io.github.cognitect-labs/test-runner/dfb30dd6605cb6c0efc275e1df1736f6e90d4d73/src/cognitect/test_runner/api.clj:28:30
exec-7a6b831b-ba00-48d8-becf-22d3f87d8245/exec - <expr>:22:1
exec-7a6b831b-ba00-48d8-becf-22d3f87d8245      - <expr>:4:1
user-6966f77b-250c-46d6-803f-3372c14518b1      - <expr>:27:46


-ERROR:--------------------------------------------------------------------------
  exited with 1 for: ["bb" "-test:bb" ":vars" "etaoin.api-test/test-visible"]    
 --------------------------------------------------------------------------------

lread 2023-03-08T16:19:41.130249Z

❯ bb tools-versions

[ TASK tools-versions  ]---------------------------------------------------------
|-------------------+-----------------------------------------------------------------------------------------------------+----------------------------------------------------|
|        Name       |                                               Version                                               |                        Path                        |
|-------------------+-----------------------------------------------------------------------------------------------------+----------------------------------------------------|
| Java              | openjdk version "17.0.6" 2023-01-17                                                                 | /home/lee/.sdkman/candidates/java/current/bin/java |
|                   | OpenJDK Runtime Environment Temurin-17.0.6+10 (build 17.0.6+10)                                     |                                                    |
|                   | OpenJDK 64-Bit Server VM Temurin-17.0.6+10 (build 17.0.6+10, mixed mode, sharing)                   |                                                    |
| Babashka          | babashka v1.2.174                                                                                   | /home/linuxbrew/.linuxbrew/bin/bb                  |
| Image Magick      | Version: ImageMagick 6.9.11-60 Q16 x86_64 2021-01-25                         | /usr/bin/identify                                  |
| Chrome            | Google Chrome 111.0.5563.64                                                                         | /usr/bin/google-chrome                             |
| Chrome Webdriver  | ChromeDriver 111.0.5563.64 (c710e93d5b63b7095afe8c2c17df34408078439d-refs/branch-heads/5563@{#995}) | /home/lee/bin/chromedriver                         |
| Firefox           | Mozilla Firefox 110.0.1                                                                             | /usr/bin/firefox                                   |
| Firefox Webdriver | geckodriver 0.32.2 (602aa16c20d4 2023-02-08 00:09 +0000)                                            | /home/lee/bin/geckodriver                          |
|-------------------+-----------------------------------------------------------------------------------------------------+----------------------------------------------------|

TASK tools-versions done.

borkdude 2023-03-08T16:19:56.463099Z

can you get rid of that retry logic so we can better see what's going wrong?

dysmento 2023-03-08T16:22:45.228149Z

If it's helpful, here's a one-liner that fails:

bb -Sdeps '{:deps {etaoin/etaoin {:mvn/version "1.0.39"}}}' -e "(require '[etaoin.api :as e]) (def driver (e/chrome))"

borkdude 2023-03-08T16:23:22.285849Z

That's very helpful but for me that just works

borkdude 2023-03-08T16:23:34.641629Z

what is your bb version?

lread 2023-03-08T16:23:45.252689Z

1.2.174

dysmento 2023-03-08T16:23:53.402199Z

v1.2.174

borkdude 2023-03-08T16:24:01.301429Z

what's the error message

dysmento 2023-03-08T16:24:19.831329Z

❯ bb -Sdeps '{:deps {etaoin/etaoin {:mvn/version "1.0.39"}}}' -e "(require '[etaoin.api :as e]) (def driver (e/chrome))"
2023-03-08T16:22:06.163Z L-SAN-220728-01 DEBUG [etaoin.api:?] - Created driver: chrome 127.0.0.1:58201
2023-03-08T16:22:06.183Z L-SAN-220728-01 DEBUG [etaoin.api:?] - Starting process: chromedriver --port=58201
2023-03-08T16:22:06.186Z L-SAN-220728-01 DEBUG [etaoin.api:?] - Waiting until 127.0.0.1:58201 is running
----- Error --------------------------------------------------------------------
Type:     clojure.lang.ExceptionInfo
Message:  gave up trying to launch :chrome after 1 tries
Data:     {}
Location: etaoin/api.clj:3504:9

----- Context ------------------------------------------------------------------
3500:   (let [max-tries (inc webdriver-failed-launch-retries)]
3501:     (loop [try-num 1
3502:            ex nil]
3503:       (if (> try-num max-tries)
3504:         (throw (ex-info (format "gave up trying to launch %s after %d tries" (:type driver) max-tries) {} ex))
              ^--- gave up trying to launch :chrome after 1 tries
3505:         (do
3506:           (when ex
3507:             (log/warnf ex "unexpected exception occurred launching %s, try %d (of a max of %d)"
3508:                        (:type driver) (dec try-num) max-tries)
3509:             (Thread/sleep 100))

----- Stack trace --------------------------------------------------------------
etaoin.api/-run-driver - etaoin/api.clj:3504:9
etaoin.api/-run-driver - etaoin/api.clj:3460:1
etaoin.api/boot-driver - etaoin/api.clj:3663:56
etaoin.api/chrome      - etaoin/api.clj:3655:4
etaoin.api/chrome      - etaoin/api.clj:3686:1
user                   - <expr>:1:43

borkdude 2023-03-08T16:24:20.540929Z

$  bb -Sdeps '{:deps {etaoin/etaoin {:mvn/version "1.0.39"}}}' -e "(require '[etaoin.api :as e]) (def driver (e/chrome))"
2023-03-08T16:24:08.574Z m1.local DEBUG [etaoin.api:?] - Created driver: chrome 127.0.0.1:51141
2023-03-08T16:24:08.581Z m1.local DEBUG [etaoin.api:?] - Starting process: chromedriver --port=51141
2023-03-08T16:24:08.583Z m1.local DEBUG [etaoin.api:?] - Waiting until 127.0.0.1:51141 is running
2023-03-08T16:24:08.920Z m1.local DEBUG [etaoin.api:?] - Waiting until 127.0.0.1:51141 is running
2023-03-08T16:24:08.925Z m1.local DEBUG [etaoin.impl.client:?] - chrome 127.0.0.1:51141   POST session {:desiredCapabilities {:loggingPrefs {:browser "ALL"}}}
#'user/driver

borkdude 2023-03-08T16:24:45.541849Z

I think the retry logic is in the way

borkdude 2023-03-08T16:24:49.914949Z

of seeing the real error

lread 2023-03-08T16:25:23.568449Z

Can bb emit the cause? The ex ? Or does not it not work that way.

3504:         (throw (ex-info (format "gave up trying to launch %s after %d tries" (:type driver) max-tries) {} ex))
              ^--- gave up trying to launch :chrome after 1 tries

borkdude 2023-03-08T16:25:54.191129Z

maybe with bb --debug, not sure

borkdude 2023-03-08T16:26:14.156179Z

I don't think it prints more than one msg. I'll just get rid of the retry logic myself and push to CI

lread 2023-03-08T16:27:00.846719Z

Ah yes.

❯ bb --debug -Sdeps '{:deps {etaoin/etaoin {:mvn/version "1.0.39"}}}' -e "(require '[etaoin.api :as e]) (def driver (e/chrome))"
2023-03-08T16:26:02.751Z pop-os DEBUG [etaoin.api:?] - Created driver: chrome 127.0.0.1:46473
2023-03-08T16:26:02.754Z pop-os DEBUG [etaoin.api:?] - Starting process: chromedriver --port=46473
2023-03-08T16:26:02.758Z pop-os DEBUG [etaoin.api:?] - Waiting until 127.0.0.1:46473 is running
----- Error --------------------------------------------------------------------
Type:     clojure.lang.ExceptionInfo
Message:  gave up trying to launch :chrome after 1 tries
Data:     {}
Location: etaoin/api.clj:3504:9

----- Context ------------------------------------------------------------------
3500:   (let [max-tries (inc webdriver-failed-launch-retries)]
3501:     (loop [try-num 1
3502:            ex nil]
3503:       (if (> try-num max-tries)
3504:         (throw (ex-info (format "gave up trying to launch %s after %d tries" (:type driver) max-tries) {} ex))
              ^--- gave up trying to launch :chrome after 1 tries
3505:         (do
3506:           (when ex
3507:             (log/warnf ex "unexpected exception occurred launching %s, try %d (of a max of %d)"
3508:                        (:type driver) (dec try-num) max-tries)
3509:             (Thread/sleep 100))

----- Stack trace --------------------------------------------------------------
etaoin.api/-run-driver - etaoin/api.clj:3504:9
etaoin.api/-run-driver - etaoin/api.clj:3460:1
etaoin.api/boot-driver - etaoin/api.clj:3663:56
etaoin.api/chrome      - etaoin/api.clj:3655:4
etaoin.api/chrome      - etaoin/api.clj:3686:1
user                   - <expr>:1:43

----- Exception ----------------------------------------------------------------
clojure.lang.ExceptionInfo: gave up trying to launch :chrome after 1 tries
{:type :sci/error, :line 3504, :column 9, :message "gave up trying to launch :chrome after 1 tries", :sci.impl/callstack #object[clojure.lang.Volatile 0x3397b914 {:status :ready, :val ({:line 1, :column 43, :ns #object[sci.lang.Namespace 0x7523ce50 "user"], :file "<expr>", :sci.impl/f-meta {:name chrome, :ns #object[sci.lang.Namespace 0x7d413ed5 "etaoin.api"], :file "etaoin/api.clj", :arglists ([] [opts]), :line 3686, :column 1, :doc "Launch and return a Chrome driver.\n\n  `opts` map is optionally, see [Driver Options](/doc/01-user-guide.adoc#driver-options)."}} {:line 3655, :column 4, :ns #object[sci.lang.Namespace 0x7d413ed5 "etaoin.api"], :file "etaoin/api.clj", :sci.impl/f-meta {:name boot-driver, :ns #object[sci.lang.Namespace 0x7d413ed5 "etaoin.api"], :file "etaoin/api.clj"}} {:line 3663, :column 56, :ns #object[sci.lang.Namespace 0x7d413ed5 "etaoin.api"], :file "etaoin/api.clj", :sci.impl/f-meta {:name -run-driver, :ns #object[sci.lang.Namespace 0x7d413ed5 "etaoin.api"], :file "etaoin/api.clj", :private true, :arglists ([driver {:keys [webdriver-failed-launch-retries], :as opts}]), :doc "Runs a driver process locally.\n\n  Creates a UNIX process with a Webdriver HTTP server. Host and port\n  are taken from a `driver` argument. Updates a driver instance with\n  new fields with process information. Returns modified driver.\n\n  Arguments:\n\n  - `driver` is a map created with `-create-driver` function.\n\n  - `opts` is an optional map with the following possible parameters:\n\n  -- `:path-driver` is a string path to the driver's binary file.\n\n  -- `:path-browser` is a string path to the browser's binary\n  file. When not passed, the driver discovers it by its own.\n\n  -- `:webdriver-failed-launch-retries` number of times to retry launching webdriver process.\n\n  -- `:log-level` a keyword to set browser's log level. Used when fetching\n  browser's logs. Possible values are: `:off`, `:debug`, `:warn`, `:info`,\n  `:error`, `:all`.\n\n  -- `:driver-log-level` a keyword to set driver's log level.\n  The value is a string. Possible values are:\n  chrome: [ALL, DEBUG, INFO, WARNING, SEVERE, OFF]\n  phantomjs: [ERROR, WARN, INFO, DEBUG] (default INFO)\n  firefox [fatal, error, warn, info, config, debug, trace]\n\n  -- `:log-stdout` and `:log-stderr`. Paths to the driver's log files as strings.\n  Specify `:inherit` to inherit destination from calling process (ex. console).\n  When not set, the output goes to /dev/null (or NUL on Windows)\n\n  -- `:args-driver` is a vector of additional arguments to the\n  driver's process.\n\n  -- `:env` is a map with system ENV variables. Keys are turned into\n  upper-case strings.", :line 3460, :column 1}} {:ns #object[sci.lang.Namespace 0x7d413ed5 "etaoin.api"], :file "etaoin/api.clj"} {:line 3504, :column 9, :ns #object[sci.lang.Namespace 0x7d413ed5 "etaoin.api"], :file "etaoin/api.clj", :special true})}], :file "etaoin/api.clj"}
 at sci.impl.utils$rethrow_with_location_of_node.invokeStatic (utils.cljc:129)
    sci.impl.analyzer$analyze_throw$reify__4264.eval (analyzer.cljc:968)
    sci.impl.analyzer$return_if$reify__4219.eval (analyzer.cljc:849)
    sci.impl.fns$fun$arity_2__1171.invoke (fns.cljc:108)
    sci.impl.analyzer$return_call$reify__4502.eval (analyzer.cljc:1402)
    sci.impl.analyzer$analyze_let_STAR_$reify__4183.eval (analyzer.cljc:629)
    sci.impl.analyzer$analyze_let_STAR_$reify__4181.eval (analyzer.cljc:618)
    sci.impl.analyzer$analyze_let_STAR_$reify__4187.eval (analyzer.cljc:663)
    sci.impl.fns$fun$arity_2__1171.invoke (fns.cljc:108)
    sci.lang.Var.invoke (lang.cljc:202)
    sci.impl.analyzer$return_call$reify__4504.eval (analyzer.cljc:1402)
    sci.impl.analyzer$return_if$reify__4219.eval (analyzer.cljc:849)
    sci.impl.analyzer$analyze_let_STAR_$reify__4181.eval (analyzer.cljc:618)
    sci.impl.analyzer$analyze_let_STAR_$reify__4185.eval (analyzer.cljc:642)
    sci.impl.analyzer$analyze_let_STAR_$reify__4189.eval (analyzer.cljc:686)
    sci.impl.fns$fun$arity_2__1171.invoke (fns.cljc:108)
    clojure.lang.AFn.applyToHelper (AFn.java:156)
    clojure.lang.AFn.applyTo (AFn.java:144)
    clojure.core$apply.invokeStatic (core.clj:667)
    sci.impl.analyzer$analyze_fn_STAR_$reify__4147$f__4148.doInvoke (analyzer.cljc:529)
    clojure.lang.RestFn.invoke (RestFn.java:421)
    sci.lang.Var.invoke (lang.cljc:202)
    sci.impl.analyzer$return_call$reify__4504.eval (analyzer.cljc:1402)
    sci.impl.fns$fun$arity_1__1166.invoke (fns.cljc:107)
    clojure.lang.AFn.applyToHelper (AFn.java:154)
    clojure.lang.AFn.applyTo (AFn.java:144)
    clojure.core$apply.invokeStatic (core.clj:667)
    sci.impl.analyzer$analyze_fn_STAR_$reify__4147$f__4148.doInvoke (analyzer.cljc:529)
    clojure.lang.RestFn.invoke (RestFn.java:408)
    clojure.core$partial$fn__5908.invoke (core.clj:2640)
    sci.lang.Var.invoke (lang.cljc:198)
    sci.impl.analyzer$return_call$reify__4496.eval (analyzer.cljc:1402)
    sci.impl.evaluator$eval_def.invokeStatic (evaluator.cljc:27)
    sci.impl.analyzer$analyze_def$reify__4206.eval (analyzer.cljc:761)
    sci.impl.interpreter$eval_form.invokeStatic (interpreter.cljc:40)
    sci.impl.interpreter$eval_string_STAR_.invokeStatic (interpreter.cljc:62)
    sci.core$eval_string_STAR_.invokeStatic (core.cljc:270)
    babashka.main$exec$fn__31074$fn__31112$fn__31113.invoke (main.clj:1042)
    babashka.main$exec$fn__31074$fn__31112.invoke (main.clj:1042)
    babashka.main$exec$fn__31074.invoke (main.clj:1032)
    clojure.lang.AFn.applyToHelper (AFn.java:152)
    clojure.lang.AFn.applyTo (AFn.java:144)
    clojure.core$apply.invokeStatic (core.clj:667)
    clojure.core$with_bindings_STAR_.invokeStatic (core.clj:1990)
    clojure.core$with_bindings_STAR_.doInvoke (core.clj:1990)
    clojure.lang.RestFn.invoke (RestFn.java:425)
    babashka.main$exec.invokeStatic (main.clj:824)
    babashka.main$main.invokeStatic (main.clj:1155)
    babashka.main$main.doInvoke (main.clj:1124)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.core$apply.invokeStatic (core.clj:667)
    babashka.main$_main$f__31186__auto____31196.invoke (main.clj:1194)
    clojure.lang.AFn.run (AFn.java:22)
    java.lang.Thread.run (Thread.java:1589)
    com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine (PlatformThreads.java:775)
    com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine (PosixPlatformThreads.java:203)

lread 2023-03-08T16:29:38.556409Z

Hmmm... firefox passes for me:

$ bb --debug -Sdeps '{:deps {etaoin/etaoin {:mvn/version "1.0.39"}}}' -e "(require '[etaoin.api :as e]) (def driver (e/firefox))"

2023-03-08T16:28:19.743Z pop-os DEBUG [etaoin.api:?] - Created driver: firefox 127.0.0.1:38401

2023-03-08T16:28:19.747Z pop-os DEBUG [etaoin.api:?] - Starting process: geckodriver --port 38401

2023-03-08T16:28:19.751Z pop-os DEBUG [etaoin.api:?] - Waiting until 127.0.0.1:38401 is running

2023-03-08T16:28:19.752Z pop-os DEBUG [etaoin.api:?] - Waiting until 127.0.0.1:38401 is running

2023-03-08T16:28:19.752Z pop-os DEBUG [etaoin.impl.client:?] - firefox 127.0.0.1:38401   POST session {:desiredCapabilities {:loggingPrefs {:browser "ALL"}}}

#'user/driver
``` Maybe we are dealing with a chrome change... but wonder why it fails only on bb, not jvm...

borkdude 2023-03-08T16:30:20.867359Z

the tests also fail for bb + edge etc

borkdude 2023-03-08T16:30:48.318609Z

:args ("chromedriver" "--port=49183") :type clojure.lang.LazySeq
----- Error --------------------------------------------------------------------
Type:     java.lang.IllegalArgumentException
Message:  No matching method sleep found taking 1 args
Location: /Users/runner/work/etaoin/etaoin/src/etaoin/api.clj:2504:8

dysmento 2023-03-08T16:30:51.399439Z

For me, (e/firefox) fails in exactly the same way. πŸ€·β€β™‚οΈ

borkdude 2023-03-08T16:31:23.521189Z

Can you try: (Thread/sleep 1000) in your bb?

lread 2023-03-08T16:31:31.209999Z

The old sleeparoo?

borkdude 2023-03-08T16:31:39.772529Z

?

borkdude 2023-03-08T16:31:52.547549Z

Just:

bb -e '(Thread/sleep 1000)'

lread 2023-03-08T16:32:18.952939Z

no errors when run

borkdude 2023-03-08T16:34:34.605399Z

it seems to go wrong in etaoin await

borkdude 2023-03-08T16:35:06.706389Z

(Thread/sleep ^long (* seconds 1000))

lread 2023-03-08T16:35:08.221739Z

@borkdude, if your day is going sideways, I can dig in.

borkdude 2023-03-08T16:36:18.945539Z

This also works for me:

bb -e '((fn [x] (Thread/sleep ^long x)) 1000)'

lread 2023-03-08T16:36:19.038619Z

ah maybe a jdk19 thread sleep signature change (what I meant by the old sleeparoo).

borkdude 2023-03-08T16:36:40.579689Z

This also works for me:

bb -e '((fn [x] (Thread/sleep ^long (inc x))) 1000)'

lread 2023-03-08T16:37:05.967109Z

the above run fine for me

borkdude 2023-03-08T16:38:29.431219Z

Btw I can also repro with the JDK19 one, I was running an old local dev build:

/opt/homebrew/bin/bb -Sdeps '{:deps {etaoin/etaoin {:mvn/version "1.0.39"}}}' -e "(require '[etaoin.api :as e]) (def driver (e/chrome))"

lread 2023-03-08T16:39:16.583979Z

oh well that's good

borkdude 2023-03-08T16:40:26.122959Z

well, at least it isn't process then

borkdude 2023-03-08T16:40:30.877619Z

but some interop thing

borkdude 2023-03-08T16:40:35.443189Z

now on to a repro

borkdude 2023-03-08T16:44:53.622589Z

I can only repro this when I don't pass a long:

(wait 1.0)

lread 2023-03-08T16:48:13.257919Z

Ditto. (wait 1) is fine, but (wait 1.0) I get No matching method sleep found taking 1 args

borkdude 2023-03-08T16:49:10.450359Z

I'll change the wait function to:

(defn wait
  "Sleep for `seconds`."
  (#_{:clj-kondo/ignore [:unused-binding]} [driver seconds]
   (wait seconds))
  ([seconds]
   (Thread/sleep (long (* seconds 1000)))))

borkdude 2023-03-08T16:49:15.327049Z

This works for both JVM 19 and bb

lread 2023-03-08T16:50:11.849549Z

Yeah that looks fine to me!

lread 2023-03-08T16:50:41.966159Z

So bb didn't grok the type hint maybe?

borkdude 2023-03-08T16:50:55.897339Z

it did but I suspect the type of the thing passed not being a long

borkdude 2023-03-08T16:51:19.692979Z

(e/wait (/ windowTimeout 1000))

dysmento 2023-03-08T16:52:14.377469Z

ratio!

lread 2023-03-08T16:53:38.827519Z

Hmmm... so jvm and bb behave differently for this. But I think your (long ...) is probably what we really want to do anyway.

lread 2023-03-08T16:55:50.522189Z

So also bb not showing exception cause made things a bit tricky to diagnose.

borkdude 2023-03-08T16:58:51.984029Z

do you run tests with jdk19?

borkdude 2023-03-08T16:59:05.097819Z

because if you don't I get why the JVM is accepting this, else not sure

lread 2023-03-08T17:00:09.677859Z

Not on CI, but did so locally. Lemme double check. (CI tests are already hugely long so only doing one jdk for now, could spot check jdk19 tho...).

lread 2023-03-08T17:01:36.682299Z

❯ java --version
openjdk 19.0.2 2023-01-17
OpenJDK Runtime Environment Temurin-19.0.2+7 (build 19.0.2+7)
OpenJDK 64-Bit Server VM Temurin-19.0.2+7 (build 19.0.2+7, mixed mode, sharing)
❯ bb test:jvm -b chrome -v etaoin.api-test/test-visible

[ TASK test:jvm -b chrome -v etaoin.api-test/test-visible ]----------------------

[ Running tests ]----------------------------------------------------------------
suites: <none specified>
browsers: chrome
runner-args: [:vars etaoin.api-test/test-visible]

Running tests in #{"test"}

Testing etaoin.api-test
Testing with browsers: [:chrome]
=== test-visible [jvm][chrome]

Ran 1 tests containing 4 assertions.
0 failures, 0 errors.

TASK test:jvm done.

lread 2023-03-08T17:02:47.324429Z

I put in that sleep fix a while ago for folks using JDK19, I expect I would have heard back from folks if there were issues.

borkdude 2023-03-08T17:07:54.043799Z

right

borkdude 2023-03-08T17:09:37.588279Z

I guess JVM Clojure puts an explicit long cast in there when emitting bytecode

lread 2023-03-08T17:10:32.509969Z

I guess it must?

borkdude 2023-03-08T17:12:08.179999Z

not if you always pass a long

borkdude 2023-03-08T17:13:29.485559Z

perhaps bb could do the long cast via the long function to fix this, but right now doing this manually works

borkdude 2023-03-08T17:13:32.877919Z

I'll make a PR after dinner

lread 2023-03-08T17:15:03.395619Z

$ clj
....
user=> (def x "foo")
#'user/x
user=> (Thread/sleep ^long x)
ClassCastException class java.lang.String cannot be cast to class java.lang.Number (java.lang.String and java.lang.Number are in module java.base of loader 'bootstrap')  user/eval156 (NO_SOURCE_FILE:12)
user=> (def x 3/4)
#'user/x
user=> (Thread/sleep ^long x)
nil

borkdude 2023-03-08T17:16:01.047399Z

right

borkdude 2023-03-08T17:16:07.430339Z

it casts to a number ?

borkdude 2023-03-08T17:16:17.887609Z

and then the JVM coerces it into a long probably

borkdude 2023-03-08T17:16:29.264129Z

would be good to inspect the bytecode with decompiler

borkdude 2023-03-08T17:16:55.910819Z

afk now, dinner time. but I will be back!

lread 2023-03-08T17:17:50.904789Z

bon appetit!

borkdude 2023-03-08T18:25:45.298059Z

yeah, but I'm also using this code in bb

borkdude 2023-03-08T18:26:06.669609Z

I'll create a separate issue about this

borkdude 2023-03-08T18:26:26.211699Z

This works:

bb -e '(Thread/sleep (/ 1 2))'

borkdude 2023-03-08T18:26:56.980899Z

No, it doesn't:

/opt/homebrew/bin/bb -e '(Thread/sleep (/ 1 2))'
----- Error --------------------------------------------------------------------

borkdude 2023-03-08T18:27:19.557839Z

this is because bb isn't passing type hints along with the reflective call

borkdude 2023-03-08T18:28:49.449589Z

https://github.com/babashka/babashka/issues/1513

borkdude 2023-03-08T19:02:33.593859Z

@lee PR ready https://github.com/clj-commons/etaoin/pull/525/files

borkdude 2023-03-08T19:02:47.453749Z

I did see a firefox failure, but I suspect that doesn't have to do with my PR

lread 2023-03-08T19:06:45.854949Z

Annoyingly, there are sporadic failures still... I typically just have GitHub Actions rerun failed jobs.

lread 2023-03-08T19:09:39.024059Z

I'll cut a release after merge.

πŸ™ 1
lread 2023-03-08T19:21:40.154489Z

Hey @borkdude, having bb somehow share an exception cause(s) would help in a situation like this. I might have missed it, but I don't see an existing bb issue for this, want one?

borkdude 2023-03-08T19:22:46.633109Z

yes, with a repro plz!

πŸ‘ 1
borkdude 2023-03-08T19:22:56.251149Z

also with a comparison to what clj does

πŸ‘ 1
dysmento 2023-03-08T19:24:10.181599Z

Y'all are amazing. I confirmed that I'm back up and running (both Chrome and Firefox) with this branch.

lread 2023-03-08T19:24:32.047089Z

Thanks for chipping in and helping @zach524, much appreciated!

dysmento 2023-03-08T19:24:41.544869Z

My pleasure.

borkdude 2023-03-08T19:25:58.959069Z

Thank you all for putting up with my grumpiness!

πŸ€— 1
dysmento 2023-03-08T19:26:37.160269Z

Maybe your day is turning around now. πŸ˜‰

πŸ™Œ 1
lread 2023-03-08T19:27:51.062969Z

And thank you for putting up with my future-grumpiness in some coming day. simple_smile

❀️ 1
borkdude 2023-03-08T19:29:47.382149Z

grump-driven development

lread 2023-03-08T19:31:21.714259Z

Well, a large portion of the Clojure community is, I hear, grumpy old men. Maybe you just got pickled in the brine.

lread 2023-03-08T19:32:14.070199Z

Blech, CI tests are flakier than I remember.

dysmento 2023-03-08T19:32:17.289189Z

In fact, I am also a grumpy old man. But Clojure is what I do to feel better. πŸ˜„

πŸ˜„ 2
lread 2023-03-08T20:17:07.650429Z

I'm gonna take a peek at that test-doc failure before merging. This might mean getting my macOS VirtualBox setup more than it is now (which might be not so easy). I'll try some quick tests in a branch first.

lread 2023-03-08T21:38:27.705349Z

Etaoin and WebDrivers. Almost as fun as YAML!

πŸ’― 1
lread 2023-03-08T21:50:21.136699Z

@borkdude regarding triggering on push, pull-request, the thing that might have irked me was that tests are triggered twice for one commit to a PR. But that's the trade-off, I guess.

borkdude 2023-03-08T21:53:32.292489Z

right. that's an issue that's bothered me with Github Actions, it's the only CI I've seen to behave like that

lread 2023-03-08T21:54:47.666269Z

It really kinda sucks. Unnecessary waste of compute.

borkdude 2023-03-08T21:54:56.115519Z

climate change πŸš€

😿 1
lread 2023-03-08T22:05:48.766109Z

I'm kinda tired of trying to get CIs to do what I'd like them to do but maybe I'll play a bit with this one sometime later. The GitHub Actions default activities for the pull_request trigger are opened, synchronize or reopened . I'm now wondering if removing synchronize would avoid the double triggering on push. https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request

shem 2023-03-09T06:20:41.120129Z

Amazing session, guys! Can confirm that with 1.0.40 this works with babashka. Still fails with jvm clojure though...

πŸ‘ 2
shem 2023-03-09T06:26:41.164299Z

no, actually it works when :headless true

lread 2023-03-09T13:41:17.139679Z

@shem that jvm issue you hit is something different. Do you need any help looking into it?

lread 2023-03-09T16:49:35.480459Z

@borkdude, as promised, bb issue: https://github.com/babashka/babashka/issues/1515

borkdude 2023-03-09T16:50:09.416969Z

<3