Fork me on GitHub

I have the following function that had been working but suddenly gives an error. Don’t know what changed:

(defn navigate! [match _]
  (prn "match is " match)
  (e/common-navigate match))
app.js:1552 TypeError: Cannot read property 'common_navigate' of undefined
    at humboi$core$navigate_BANG_ (core.cljs:257)
    at reitit$frontend$easy$start_BANG__$_rfe_on_navigate (easy.cljs:39)
    at Object.eval [as reitit$frontend$history$History$_on_navigate$arity$2] (history.cljs:128)
    at Object.reitit$frontend$history$_on_navigate [as _on_navigate] (history.cljs:12)
    at Object.eval [as reitit$frontend$history$History$_init$arity$1] (history.cljs:125)
    at Object.reitit$frontend$history$_init [as _init] (history.cljs:10)
    at Function.eval [as cljs$core$IFn$_invoke$arity$3] (history.cljs:170)
    at Object.reitit$frontend$easy$start_BANG_ [as start_BANG_] (easy.cljs:36)
    at Object.humboi$core$start_router_BANG_ [as start_router_BANG_] (core.cljs:487)
    at Object.humboi$core$init_BANG_ [as init_BANG_] (core.cljs:504)
the e/ namespace definitely exists.


Here’s the namespace declaration of the file that navigate! is in:

1   (:require
    2    []
    3    [reagent.dom :as rdom]
    4    [reagent.core :as r]
    5    [re-frame.core :as rf]
--  6    [ :as events]
--  7    [goog.history.EventType :as HistoryEventType]
    8    [markdown.core :refer [md->html]]
    9    [humboi.ajax :as ajax]
   10    [reitit.core :as reitit]
   11    [reitit.frontend.easy :as rfe]
   12    [clojure.string :as string]
-- 13    ["@typeform/embed-react" :refer [PopupButton]]
-- 14    [cljs.core.async :refer [go]]
-- 15    [cljs.core.async.interop :refer-macros [<p!]]
   16    #_["use-magic-link" :as useMagicLink]
   17    #_[accountant.core :as accountant]
   18    [ :as e]
   19    [humboi.subs :as s]
-- 20    [react :refer [useEffect]]
   21    [react-calendar :default Calendar])
And this is the e/ namespace’s ns declaration:


1   (ns
--  1   (:require-macros [humboi.macros :refer [db-event fx-event sub]]
    2                    [humboi.env :refer [endpoint blockchain-provider]])
    3   (:require
--  4    [re-frame.core :refer [reg-event-fx reg-fx] :as rf]
    5    [ajax.core :as ajax]
    6    [reitit.frontend.easy :as rfe]
    7    [reitit.frontend.controllers :as rfc]
    8    [cljs.core.async :refer [go]]
    9    [cljs.core.async.interop :refer-macros [<p!]]
   10    ["magic-sdk" :refer [Magic]]
   11    ["@magic-ext/oauth" :refer [OAuthExtension]]
-- 12    [humboi.macros :refer [deep-merge]]
-- 13    [humboi.subs :as s]
-- 14    [web3 :as Web3]
-- 15    ["@metamask/detect-provider" :as detectEthereumProvider]
   16    ["@alch/alchemy-web3" :refer [createAlchemyWeb3]]))


even (find-ns ' gives nil in the first file


@ps were there any errors during load? if the file didn't load properly then the ns doesn't exist


yeah there’s this error: WebSocket connection to ‘<ws://localhost:9630/api/remote-relay?server-token=36e8c857-da4b-402d-a82e-e8ad3f2b895a>’ failed:


the error you posted could just be a symptom not the cause



shadow-cljs - remote-error Event {isTrusted: true, type: "error", target: WebSocket, currentTarget: WebSocket, eventPhase: 2, …}bubbles: falsecancelBubble: falsecancelable: falsecomposed: falsecurrentTarget: WebSocket {url: "", readyState: 3, bufferedAmount: 0, onopen: null, onerror: null, …}defaultPrevented: falseeventPhase: 0isTrusted: truepath: []returnValue: truesrcElement: WebSocket {url: "", readyState: 3, bufferedAmount: 0, onopen: null, onerror: null, …}target: WebSocket {url: "", readyState: 3, bufferedAmount: 0, onopen: null, onerror: null, …}timeStamp: 166289.09999990463type: "error"[[Prototype]]: Event
eval @ shared.cljs:305
shadow$cljs$devtools$client$shared$remote_error @ shared.cljs:18
eval @ websocket.cljs:29
error (async)
shadow$cljs$devtools$client$websocket$start @ websocket.cljs:26
eval @ shared.cljs:324
eval @ shared.cljs:345
setTimeout (async)
eval @ shared.cljs:341
eval @ shared.cljs:297
shadow$cljs$devtools$client$shared$remote_close @ shared.cljs:17
eval @ websocket.cljs:24


no clue. websocket should connect properly if everything is setup properly


but I don't know anything about your setup so can't comment much


there are 9 cannot infer target type warnings, including warnings from the file with ns Other than that it says build completed


either fix them or turn them off. do not ignore warnings.


Tried ^js tags everywhere but the warning didn’t go away. The warning points to go:

1       (go
    2         (let [web3 (createAlchemyWeb3 (blockchain-provider))]
    3             (js/console.log "deploying contract "
    4                            (.-issuer (-> db :user))
    5                            "."
    6                            "web3" web3
    7              (.then
    8                (.send
    9                    (.buy
   10                      (.-methods
   11                        (new (.. web3 -eth -Contract)
   12                             (:contract-json db)
   13                             (-> db :creation :creation/contract-address)))
   14                      ;; magic id
   15                      (.-issuer (-> db :user)))
   16                    (clj->js {:value (* (:creation-input-value db)
   17                                        1000000000000000000)
   19                              :from (->
   20                                      (<p!
   21                                       (.request
   22                                        (:ethereum db) (clj->js {:method "eth_      requestAccounts"})))
   23                                      (get 0))})
   24                   (fn [err transaction-hash]
   25                     (prn "err is;; " err)
   26                     (prn "transaction has is " transaction-hash)))
   27               (fn [contract-instance]
   28                  (js/console.log "new contract instance is " contract-instanc      e))))))


Cannot infer target type in expression (. inst_62878 (buy inst_62880))


^js tags don't work properly in go


you probably shouldn't mix .then and <p!, pick one and stay with it


so is there a way to fix the warning?


not easily in go. you can (set! *warn-on-infer* false) directly after the ns to turn warnings off for that file


Adding that to gives a new error:

browser.cljs:39 Failed to load humboi/events.cljs SyntaxError: Unexpected token '.'
    at eval (<anonymous>)
    at (app.js:486)
    at Object.shadow$cljs$devtools$client$browser$script_eval [as script_eval] (browser.cljs:24)
    at Object.shadow$cljs$devtools$client$browser$do_js_load [as do_js_load] (browser.cljs:36)
    at eval (browser.cljs:57)
    at eval (env.cljs:236)
    at Object.shadow$cljs$devtools$client$env$do_js_reload_STAR_ [as do_js_reload_STAR_] (env.cljs:208)
    at Function.eval [as cljs$core$IFn$_invoke$arity$4] (env.cljs:244)
    at Object.shadow$cljs$devtools$client$browser$do_js_reload [as do_js_reload] (browser.cljs:43)
    at eval (browser.cljs:93)
But it doesn’t say what line the . is on


If it knows that there’s this specific syntax error, shouldn’t it say what line it is on?


And the file is so large that I couldn’t really find it manually


sorry I don't know. I don't know what you are doing in the file. the snippet you posted has some weird things that look suspicious. what is {:method "eth_ requestAccounts"} or (js/console.log "new contract instance is " contract-instanc e)


also this is way too large number for safe JS math (* (:creation-input-value db) 1000000000000000000)

Ella Hoeppner23:08:55

Hi, I'm working on a shadow-cljs project that involves using a SharedArrayBuffer to communicate with a worklet. A few days ago the app stopped working properly, and after some research I've found out that SharedArrayBuffers no longer work by default in chrome as of version 92 without specifying certain HTTP headers. How would I go about doing this in shadow-cljs?

Ella Hoeppner23:08:31

I see here that you're supposed to be able to specify headers in shadow-cljs.edn with :push-state/headers , but that doesn't seem to be working. Not sure why. Here's the relevant snippet:

:dev-http {9500 {:root "public"
                  :push-state/headers {"content-type" "text/html"
                                       "Cross-Origin-Opener-Policy" "same-origin"
                                       "Cross-Origin-Embedder-Policy" "require-corp"}}}