Fork me on GitHub
#shadow-cljs
<
2024-06-10
>
borkdude10:06:09

Anyone else ran into the file watcher not working under GraalVM 22?

Execution error (NoSuchMethodError) at com.oracle.truffle.api.library.LibraryFactory/ensureLibraryInitialized (LibraryFactory.java:384).
'void sun.misc.Unsafe.ensureClassInitialized(java.lang.Class)'

thheller12:06:05

what makes you say that this is filewatcher related?

borkdude12:06:01

the stack trace suggested it

borkdude12:06:22

and it happened with shadow-cljs watch

thheller12:06:52

are you on macos?

borkdude12:06:30

GraalVM 21 working fine

thheller12:06:41

macos uses the directory-watcher lib, otherwise the default built-in JVM thing is used

thheller12:06:53

so I'd investigate that maybe?

borkdude12:06:59

I see: io.methvin.watchservice.MacOSXListeningWatchService;

thheller12:06:01

yep, thats the one

borkdude12:06:20

ok, I'll look into it

andrea.crotti13:06:34

I'm having the same issue

borkdude14:06:03

@U5H74UNSF I'm going to take a look at this as part of nextjournal/beholder

borkdude14:06:34

@U0524T275 Ah that is a slightly different GraalVM 22 issue though - EDIT - it's related to the same removal of sun.misc.Unsafe

thheller14:06:18

I wonder it the JVM built-in watcher works better for macOS these days? people used to complain that it was too slow. basically never checked this again since java8?

andrea.crotti14:06:23

well interestingly with asdf I installed adoptjdk

andrea.crotti14:06:31

and it works with 11 or 17

andrea.crotti14:06:52

with the previous temurin it didn't work for any version for me

borkdude12:06:42

weirdly enough I can't reproduce this anymore with graalvm-jdk-22.0.1+8.1

borkdude12:06:49

I can reproduce with nextjournal.markdown though, not with nextjournal.beholder nor with shadow

hanDerPeder10:06:16

compiling this

(ns test)
(defn ^:export init []
  (println #inst "2022-02-02"))
using shadow-cljs 2.25.4 onwards emits the following error:
Failed writing cache for test: java.lang.Exception: Not supported: class java.time.Instant
In the changelog it mentions adding root-source-info to the analysis env. Could this be the cause?

thheller12:06:28

no. normally #inst does not return a java.time.Instant? do you have data_readers.clj that overwrites the default?

hanDerPeder12:06:16

this is a clean (I think) repo with only shadow

thheller12:06:29

shadow.user=> (type #inst "2022-02-02")
java.util.Date

thheller12:06:39

what do you get? npx shadow-cljs clj-repl?

thheller13:06:55

"2.25.4"why is that no using the latest shadow-cljs? I don't really care investigating things that might be fixed?

thheller13:06:08

shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (119 files, 118 compiled, 0 warnings, 5.79s)

thheller13:06:11

works fine for me?

thheller13:06:51

do you maybe start via cider-jack-in or something along those line? injecting extra dependencies from the command line maybe?

hanDerPeder13:06:41

oh sorry, I was looking back to when it was introduced, updated the repo

thheller13:06:02

I ran npx shadow-cljs watch app and get warnings or so?

hanDerPeder13:06:32

I'm seeing this

$  npx shadow-cljs release :app
shadow-cljs - config: /Users/peder/scratch/shadow-cache-issue/shadow-cljs.edn
shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
[:app] Compiling ...
Failed writing cache for test: java.lang.Exception: Not supported: class java.time.Instant
[:app] Build completed. (45 files, 2 compiled, 0 warnings, 5.22s)

hanDerPeder13:06:04

anything outside the repo that could be causing this?

hanDerPeder13:06:29

we're seeing it in ci as well

thheller13:06:39

ha, ok getting it for release as well. watch is fine. weird.

👍 1
thheller13:06:39

FWIW I would strongly caution against using custom reader literals in code

hanDerPeder13:06:03

for existing types or in general?

thheller13:06:04

but regardless, no sure what that might be. will look into it later. its not a critical error, just won't have cache for that file

hanDerPeder13:06:42

we pull in stuff like this: https://github.com/henryw374/time-literals you recommend against that?

thheller13:06:51

yes, 100%. I'd never consider using that.

hanDerPeder13:06:38

I'd ask why, but I imagine you've explained your stance several times 😄

thheller13:06:25

precisely due to issues such as this one. reader literals create objects that the compiler then has to deal with. in CLJ that has very much the same issues when it comes to AOT compilation.

👍 1
thheller13:06:14

I'm unsure how something turns from a Date to an Instant, so thats weird. especially given that release and watch use the same caching code, so why does watch not trigger it

hanDerPeder13:06:32

yeah, I dunno. It happened somewhere between 2.25.3 and 2.25.4. not sure if there are more changes then the changelog lets on

thheller13:06:37

well, you correctly identified the cause. it was that change, since that adds the form to the analyzer data. what I'm unsure is how it becomes a java.time.Instant when it should be a java.util.Date

thheller13:06:22

what is even weirder is that I can't reproduce this in the shadow-cljs project directly

😳 1
thheller14:06:53

should be fixed in 2.28.9

hanDerPeder15:06:23

thanks! did you figure out why it happened?

thheller15:06:00

no, but the issue is more general than just #inst since it would basically happen for any literal. so removed that case entirely.

👍 1