Skip to content

Commit dc6b34e

Browse files
theaspptaoussanis
authored andcommitted
[fix] [#448] [#453] Don't add beforeunload event listener when running inside NodeJS (@theasp)
This solves this problem: ``` SHADOW import error /home/asp/projects/xxx/.shadow-cljs/builds/server/dev/out/cljs-runtime/taoensso.sente.js /home/asp/projects/xxx/target/private/js/server.js:64 /* ignore this, look at stacktrace */ fn.call(global, require, module, __filename, __dirname); ^ TypeError: goog.global.addEventListener is not a function at /home/asp/projects/xxx/.shadow-cljs/builds/server/dev/out/cljs-runtime/taoensso/sente.cljc:1353:4 at global.SHADOW_IMPORT (/home/asp/projects/xxx/target/private/js/server.js:64:44) at /home/asp/projects/xxx/target/private/js/server.js:1624:1 at Object.<anonymous> (/home/asp/projects/xxx/target/private/js/server.js:1638:3) at Module._compile (node:internal/modules/cjs/loader:1233:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1287:10) at Module.load (node:internal/modules/cjs/loader:1091:32) at Function.Module._load (node:internal/modules/cjs/loader:938:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12) at node:internal/main/run_main_module:23:47 ```
1 parent 90f988d commit dc6b34e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/taoensso/sente.cljc

+3-2
Original file line numberDiff line numberDiff line change
@@ -1350,8 +1350,9 @@
13501350

13511351
(def client-unloading?_ (atom false))
13521352
#?(:cljs
1353-
(.addEventListener goog/global "beforeunload"
1354-
(fn [event] (reset! client-unloading?_ true) nil)))
1353+
(when-not node-target?
1354+
(.addEventListener goog/global "beforeunload"
1355+
(fn [event] (reset! client-unloading?_ true) nil))))
13551356

13561357
(defn- retry-connect-chsk!
13571358
[chsk backoff-ms-fn connect-fn retry-count]

0 commit comments

Comments
 (0)