dirac

Dirac v1.7.2 is out: https://github.com/binaryage/dirac/releases/tag/v1.7.2
qqq 2017-02-19T00:00:22.002334Z

yes; I admit it's not optimal; but I figure if I get it working barely, someone more qualified will get annoyed enough to get it working flawlessly 🙂

martinklepsch 2017-02-19T05:46:41.002339Z

Has anyone attempted to get goog.log to work with devtools custom formatters?

2017-02-19T13:08:59.002343Z

@martinklepsch just looked briefly and it looks like it won’t be easily possible - goog.log logging apis are string-based, they expect a msg parameter which is either a string or 0-arity function returning a string[1], so there is no easy way how to pass a message with additional objects to be printed via console.log using custom formatters [1] https://github.com/google/closure-library/blob/d54d6df5f9094dea2f3b570822103982c300029a/closure/goog/debug/logger.js#L42

2017-02-19T13:10:23.002345Z

I could imagine some hack of creating a format string (of type string) which would have additional “hidden” property gathering all formatted objects and custom handler which would pass those as additional parameters to console.log

2017-02-19T13:23:39.002346Z

something along these lines: https://gist.github.com/darwin/6b229ece516861ebfb97f4daa28b9869

martinklepsch 2017-02-19T14:13:06.002348Z

@darwin looked a bit more into it as well. I think it could be achieved by creating a custom formatter the default console formatter is goog.debug.TextFormatter or something like that. You could probably create one that logs objects as is (which is whats required for custom formatters to work if I understand correctly)

2017-02-19T14:19:37.002349Z

I don’t see any implementation in closure-library which would provide an implementation for logging into js/console

2017-02-19T14:19:51.002350Z

goog.debug.TextFormatter does not exist

2017-02-19T14:22:56.002351Z

I’m not sure if I understand your sentence. By “creating a custom formatter” you mean creating a handler for goog.logger, not a custom formatter for Chrome DevTools, right?

2017-02-19T14:25:41.002353Z

anyways, if you look at logger apis defined in goog.debug.logger, you can see that the functions you would want to use for logging have string signatures: e.g. goog.debug.Logger.prototype.log expects msg as a string, so I don’t understand how you could do "You could probably create one that logs objects as is”, you have no good way how to pass multiple non-string parameters there without hacks

2017-02-19T14:26:03.002354Z

anyways, not my problem 🙂 I’m not going to use this personally

2017-02-19T16:05:55.002356Z

Latest ClojureScript commit broke devtools. Not quite sure whether hacking around private should be the answer.

2017-02-19T16:44:02.002357Z

ah, I see, they made cljs.core/fast-path-protocols private

2017-02-19T16:45:40.002358Z

@deas I will hack around that, private is just a flag, not a big deal

👍 1
2017-02-19T16:55:06.002360Z

Sure, was just wondering whether the hack is what we want. :)

2017-02-19T17:08:37.002362Z

I don’t think we have a better option, the problem with this whole namespace is that the functionality is very fragile and can break anytime: https://github.com/binaryage/cljs-devtools/blob/master/src/lib/devtools/munging.cljs#L2-L18

2017-02-19T17:10:01.002364Z

didn’t find a better way, changing cljs internals to make this easier for cljs-devtools is not a viable option, that could break existing code and there are more important things for dnolen to spend his brain cycles on

2017-02-19T18:47:03.002367Z

@darwin Didn't see a cleaner alternative either. Thanks!

👍 1
qqq 2017-02-19T20:42:34.002371Z

in dirac, when using "pause on exception", is it possible to have "reload the page when the page reloads" ?

qqq 2017-02-19T20:43:12.002372Z

so right now, when using dirac (1) I save file in emacs (2) boot recompiles (3) boot normally would ahve browser reload (4) but dirac pauses all this ==> I'd prefer to have dirac reload on these events

2017-02-19T20:44:01.002373Z

well, what about not pausing on exceptions?

2017-02-19T20:44:15.002374Z

or change your code to not throw during reload

2017-02-19T20:44:51.002375Z

dirac is not special in this, this is devtools behaviour, or maybe I’m missing your point?

qqq 2017-02-19T20:45:11.002376Z

I think you're understanding it correctly. This is probably devtools, not dirac behavior.

qqq 2017-02-19T20:45:43.002377Z

my "dev cycle" is (1) write some code, (2) get exception in dirac, (3) write some more code in emacs, (4) hit command-R in dirac because it's not auto reloading

2017-02-19T20:47:24.002378Z

I see, this can be annoying, but how should dirac/devtools possibly know that the exception you got is this kind of exception caused by your hot-reloading and not due to normal operation?

2017-02-19T20:48:12.002379Z

if you have enabled pausing on (unhandled) exceptions and something caused an (unhandled) exception, the code stops in debugger. period.

qqq 2017-02-19T20:49:13.002380Z

I see: (1) my desired behavior of "give me stack trace on exception" requires that dirac/devtools pauses execution of ALL code (2) my desire behavior of "save in emacs -> boot recompile -> reload" requires that the js is continuing to run (to reload) so I can't have both at the same time unless boot, outside of websockets, talks to dirac/devtools on some other port to specify "dude, we're going to do a reload, allow code execution again"

2017-02-19T20:49:27.002381Z

in theory I can imagine implementation of hot-reloader in dirac itself, that would enable hot-reloading even while paused on a breakpoint

qqq 2017-02-19T20:49:32.002382Z

but as long as "reload code" is being patched through websockets/http, dirac/devtools can't separate these two

qqq 2017-02-19T20:49:51.002383Z

thanks for walking me through this logic

qqq 2017-02-19T20:50:08.002384Z

you know what's the easiest/hackiest solution?

qqq 2017-02-19T20:50:22.002385Z

in emacs, add a on-save-hook which tells chrome canary to refresh 🙂

qqq 2017-02-19T20:50:42.002386Z

actually no, it'd have to be in boot as it needs to trigger after the recompilation

2017-02-19T20:52:32.002387Z

when stopped in the debugger, there is no chance hot-reloader could do any work - boot’s hot reloader is living in the app’s js context

qqq 2017-02-19T20:52:51.002388Z

right, but chrome canary and boot are running on the same computer

qqq 2017-02-19T20:53:02.002389Z

so boot can make some type of system call to tell another app to run f-5

qqq 2017-02-19T20:53:20.002390Z

"boot sending chorme canary rrefresh signal" <-- not via websocket, via applescript or something

2017-02-19T20:54:42.002391Z

yes, that could work

2017-02-19T20:55:23.002392Z

I was thinking about solutions through dirac, this image might help: https://github.com/binaryage/dirac/blob/master/docs/about-repls.md#dirac--figwheel your boot’s hot-reloader is the same box as “figwheel support”, you would have to move it into “javascript execution context of Dirac DevTools fork"

2017-02-19T20:55:40.002394Z

but that would be pretty difficult exercise

2017-02-19T20:55:50.002395Z

but proper solution IMO

2017-02-19T20:56:38.002396Z

for example if I did this with that figwheel support box, I would get Figwheel’s code patching and compilation feedback HUD even when stopped on a breakpoint

qqq 2017-02-19T22:18:31.002398Z

does dirac try to print metadata of objects?

qqq 2017-02-19T22:18:50.002399Z

I'm getting weird "maximum call stack size exceeded" on very small datastrcutures, but these data structures have an alter-meta! to point the meta data back at itself

2017-02-19T22:20:36.002400Z

dirac does not care, this is cljs-devtools’s job to present clojurescript datastructures in the console, do you have an example of the stack trace?

2017-02-19T22:20:50.002401Z

https://github.com/binaryage/cljs-devtools

qqq 2017-02-19T22:20:59.002403Z

I have objects that look like this: ` (def x {}) (alter-meta! x (fn [old] (assoc old :foo x)))

qqq 2017-02-19T22:21:04.002404Z

let me try to get a minimal failure care

qqq 2017-02-19T22:21:50.002405Z

oh sorry, the fault isn't even dirac's; the particular error is: "CLJS DevTools Error: Maximum call stack size exceeded"

2017-02-19T22:22:11.002406Z

and you should see some call stack, no?

qqq 2017-02-19T22:22:34.002407Z

yes let me copy/paste it (on separate machines)

2017-02-19T22:23:02.002408Z

this looks like a bug to me, but likely a bug in some printing code, not in cljs-devtools itself

2017-02-19T22:23:48.002409Z

cljs-devtools asks clojurescript to print the data structure, and clojurescript prints what it can or defer to IPrintWithWriter protocol if avail

2017-02-19T22:24:15.002410Z

so if there is a bug in some code there, cljs-devtools will report internal error

qqq 2017-02-19T22:24:25.002411Z

RangeError: Maximum call stack size exceeded
    at Object.cljs$core$array_index_of_keyword_QMARK_ [as array_index_of_keyword_QMARK_] (core.cljs:6044)
    at Object.cljs$core$array_index_of [as array_index_of] (core.cljs:6082)
    at Object.cljs$core$array_map_index_of [as array_map_index_of] (core.cljs:6095)
    at cljs.core.PersistentArrayMap.cljs$core$ILookup$_lookup$arity$3 (core.cljs:6275)
    at cljs.core.PersistentArrayMap.cljs$core$ILookup$_lookup$arity$2 (core.cljs:6272)
    at Function.cljs.core.get.cljs$core$IFn$_invoke$arity$2 (core.cljs:1832)
    at cljs.core.Keyword.cljs$core$IFn$_invoke$arity$1 (core.cljs:3162)
    at Object.cljs$core$pr_writer [as pr_writer] (core.cljs:9354)
    at cljs$core$pr_seq_writer (core.cljs:9359)
    at printing.cljs:141 
^^ this is a diferent object, let me try to get a minimal object that riggers this

2017-02-19T22:24:27.002412Z

but not necessarily a bug in cljs-devtools itself

qqq 2017-02-19T22:30:49.002413Z

(still working on minimal eaxmple) did dirac just go from 1.1.4 to 1.1.5? I restarted chromecanary and repl complained to me to use 1.1.5 instead of 1.1.4

2017-02-19T22:31:10.002414Z

yes, chrome extension auto-updates

2017-02-19T22:32:15.002417Z

simply bump your dirac dependency to 1.1.5 and restart your repl and recompile project

qqq 2017-02-19T22:32:24.002418Z

yeah ,just didthat

qqq 2017-02-19T22:35:25.002419Z

okay, in the dirac repl, I now have created an object "foo" where:

&gt; foo
CLJS DevTools Error: Maximum call stack size exceeded
&gt; (str foo)
"[:tex-space 30 20 5]"
if I can extract this object foo out, this would be a minimal failure case? (or a "small enough" failure case) ?

qqq 2017-02-19T22:38:32.002421Z

@darwin : I have a minimal failure case now:

(in the dirac repl)
&gt; (def x [:foo 1])
&gt; (alter-meta! x #(assoc % :ref x))
CLJS DevTools Error: maximum call stack size exceeded
&gt; (str x)
"[:foo 1]"

qqq 2017-02-19T22:39:30.002422Z

@dawin: is there anything else I can do to help debug this?

2017-02-19T22:39:40.002423Z

I’m going to try it myself now

2017-02-19T22:40:33.002424Z

there used to be a guard against infinite recursion, data printing has max-level and max-length, those should stop recursion

2017-02-19T22:40:38.002425Z

unless you redefined them

qqq 2017-02-19T22:43:38.002426Z

I don't think I redefined any of them.

qqq 2017-02-19T22:43:45.002427Z

I'd prefer it just not even show meta data

2017-02-19T22:44:31.002428Z

btw. there are some tests for circular data structures in cljs-devtools: https://github.com/binaryage/cljs-devtools-sample/blob/master/src/tests/devtools_sample/tests/lab.cljs#L107 but not via circular metadata, I’m going to investigate it now

qqq 2017-02-19T22:45:41.002430Z

I suspect, with 0 evidence, is that cljs-devtools is trying to eagerly generate the DOM elements for the meta data, which is then causing the infinite loop // which I guess can only be fized by making the DOM visualization lazy

2017-02-19T22:45:43.002431Z

good news, I was able to reproduce your behaviour

qqq 2017-02-19T22:45:51.002432Z

yay 🙂 your problem now 🙂

2017-02-19T22:46:02.002433Z

not necessarily, until confirmed 🙂

2017-02-19T22:55:31.002436Z

will look at it later, subscribe to https://github.com/binaryage/cljs-devtools/issues/35

qqq 2017-02-19T22:59:44.002438Z

@darwin: please tell me this is new record for time from "dirac installs" to "dirac bug report" 🙂

2017-02-19T23:00:25.002439Z

no, this is not a dirac bug, you are being offtopic for the whole time 😉