Fork me on GitHub
#shadow-cljs
<
2019-06-02
>
chepprey02:06:41

When I save changes from emacs, my "state" (like any atoms that get defined) are all reset. But any "running" go-loops seem to multiply. I'm not sure how to avoid this. If I define an "started-up" atom flag to guard against a go-loop getting spun up more than once, my flag gets reset back to false each time I save changes, so I can't prevent multiple go-loops from starting up. How can I enforce having any go-loop only starting up one time, regardless of how many times I hit save in my editor?

gklijs03:06:07

There is defonce to prevent declaring multiple times. The second time it will reuse the same atom. Might also fix the starting multiple go-loops. Something else to watch out for is having functions executed instead of only defined. So reloading will just update functions and nothing else.

chepprey04:06:50

Thanks! I'll give defonce a try. Not sure I follow the bit about functions executed vs defined on "reload" (does "reload" mean browser reload? or save in editor? or both?)

gklijs06:06:59

For example you could have something like (start-loop "foo" "bar") somewhere but then you start a new loop each time the code reloads. So you want to either start it by some action, or in some file that is not reloaded.

chepprey12:06:50

Ahhh ok, good call-out. Thanks again 👌

Ahmed Hassan07:06:47

What does this error mean in cider-nrepl while connecting with cider-connect-sibling-cljs?

yenda07:06:34

is loading of cljs modules implemented on react-native?

thheller07:06:13

@ahmed1hsn that means the embedded server was not started. see https://shadow-cljs.github.io/docs/UsersGuide.html#embedded

Ahmed Hassan07:06:34

@thheller when embedded server is started I don't need to run npx shadow-cljs watch main? Because I have already running this command in another shell before runnning cider-connect-sibling-cljs.

thheller07:06:38

@yenda as far as I know react-native and/or metro do not support loading code dynamically

thheller07:06:12

@ahmed1hsn if you have shadow-cljs watch running then you do not need the embedded server. you are likely just not connected to the correct shadow-cljs instance

thheller07:06:33

I don't use emacs so I can't help much. don't know how current this is https://shadow-cljs.github.io/docs/UsersGuide.html#cider

Ahmed Hassan08:06:34

How do I find correct shadow-cljs instance?

Ahmed Hassan08:06:48

It's still giving same errors.

yenda08:06:06

@thheller they have introduced inline requires fairly recently

thheller08:06:21

@ahmed1hsn the easiest way is to configure a fixed port for nrepl and connect to that remotely https://shadow-cljs.github.io/docs/UsersGuide.html#nREPL

thheller08:06:50

@yenda hmm it seems to be built directly on require so no cljs :modules would not work for that

Ahmed Hassan09:06:36

@thheller it works.

flyboarder20:06:00

Are we still not able to disable source map support?

flyboarder20:06:11

SHADOW import error /Users/matt/.boot/cache/tmp/Users/matt/Projects/cannabit/cannabit-identity/ukm/fyoiyj/app/cljs-runtime/app.server.js
/Users/matt/.boot/cache/tmp/Users/matt/Projects/cannabit/cannabit-identity/ukm/fyoiyj/node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js:539
      throw new TypeError('Line must be greater than or equal to 1, got '
      ^

TypeError: Line must be greater than or equal to 1, got null
    at BasicSourceMapConsumer.SourceMapConsumer_findMapping [as _findMapping] (/Users/matt/.boot/cache/tmp/Users/matt/Projects/cannabit/cannabit-identity/ukm/fyoiyj/node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js:539:13)
    at BasicSourceMapConsumer.SourceMapConsumer_originalPositionFor [as originalPositionFor] (/Users/matt/.boot/cache/tmp/Users/matt/Projects/cannabit/cannabit-identity/ukm/fyoiyj/node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js:604:22)
    at mapSourcePosition (/Users/matt/.boot/cache/tmp/Users/matt/Projects/cannabit/cannabit-identity/ukm/fyoiyj/node_modules/source-map-support/source-map-support.js:199:42)
    at wrapCallSite (/Users/matt/.boot/cache/tmp/Users/matt/Projects/cannabit/cannabit-identity/ukm/fyoiyj/node_modules/source-map-support/source-map-support.js:343:20)
    at /Users/matt/.boot/cache/tmp/Users/matt/Projects/cannabit/cannabit-identity/ukm/fyoiyj/node_modules/source-map-support/source-map-support.js:378:26
    at Array.map (<anonymous>)
    at Function.prepareStackTrace (/Users/matt/.boot/cache/tmp/Users/matt/Projects/cannabit/cannabit-identity/ukm/fyoiyj/node_modules/source-map-support/source-map-support.js:377:24)
    at process.emit (/Users/matt/.boot/cache/tmp/Users/matt/Projects/cannabit/cannabit-identity/ukm/fyoiyj/node_modules/source-map-support/source-map-support.js:431:52)
    at process._fatalException (internal/process/execution.js:123:25)

flyboarder20:06:22

I am getting this when I try to use express-session

thheller20:06:03

I don't see shadow-cljs in that stacktrace anywhere?

thheller20:06:52

is it just failing to parse the source map and swallows the actual error?

flyboarder20:06:43

@thheller that seems likely

flyboarder20:06:52

anyway to disable source maps?

flyboarder20:06:09

in release I get Maximum call stack exceeded

thheller20:06:40

well it would help to find out whats wrong. :compiler-options {:source-map false} disables them

emil0r20:06:03

Getting that error when trying to use mqtt.js

emil0r20:06:22

and the file exists under node_modules >_<

emil0r20:06:42

shadow$provide[“module$node_modules$process_nextick_args$index”] = function(global,process,require,module,exports,shadow$shims) { ‘use strict’;

emil0r20:06:19

bit perplexed as i had it working with figwheel

thheller20:06:37

had what working? please provide some example code I can run or so

emil0r20:06:10

(mqtt/connect (:uri mqtt-opts) (clj->js (:opts mqtt-opts))) is the offending line

emil0r20:06:28

and mqtt is required with [“mqtt” :as mqtt]

emil0r20:06:55

had it working in another project where i’m using figwheel

emil0r20:06:17

logs show it starts to connect and then complains about a missing function in process.nextTick

thheller20:06:39

and for figwheel you used cljsjs?

emil0r20:06:40

but it appears that the file providing process is there

emil0r20:06:52

installed mqtt via yarn

thheller20:06:12

for figwheel?

emil0r20:06:20

no, for this project

emil0r20:06:44

cljsjs for the figwheel project, yarn for this project

thheller20:06:59

well I know why process.nextTick is missing. just need to figure out why its not missing in the cljsjs packages since process.nextTick is usually a node function

thheller20:06:05

and doesn't normally exist in the browser

emil0r20:06:17

it appears to be compiled though. is it an issue of ordering? it’s required at a later stage?

thheller20:06:40

hmm yeah the polyfill is included. you can get the same if you just use (:require ["mqtt/dist/mqtt" :as mqtt]) instead

thheller20:06:20

I should probably update the process polyfill that shadow-cljs includes. seems to be a bit dated by now

emil0r20:06:48

did the trick

emil0r20:06:02

how do you track down these errors @thheller? years and years of experience with the npm ecosystem or is there rhyme and reason to it?

thheller20:06:42

thats where process comes from in browser builds

thheller20:06:00

so its clear why process.nextTick doesn't exist

thheller20:06:14

but typically JS libs do something and don't use process in browser builds

thheller20:06:28

guess this one doesn't

thheller20:06:44

only having the minimal polyfill because of that

thheller20:06:24

but the polyfill I copied has nextTick support now so I guess that should be added

emil0r20:06:30

:+1::skin-tone-2: