Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node.js support #31

Closed
tlightsky opened this issue Aug 4, 2016 · 18 comments
Closed

Node.js support #31

tlightsky opened this issue Aug 4, 2016 · 18 comments

Comments

@tlightsky
Copy link

can dirac connect to my repl in nodejs(cljs)

@darwin
Copy link
Member

darwin commented Aug 4, 2016

I believe all pieces for first-class nodejs support are in place:

  1. you run your nREPL server, with Dirac Agent
  2. you add Dirac runtime into your nodejs app
  3. you can use Dirac DevTools to debug your nodejs app[1]

#3 is very recent addition to DevTools, it should work, but Chrome devs are still fixing bugs.
#2 Dirac runtime should not care if it runs in browser context or nodejs context (I believe)

I have never tried this setup myself. It would be cool to create a sample project for nodejs app working with Dirac. Unfortunately I'm not going to spend time on this task ATM.

[1] https://medium.com/@paul_irish/debugging-node-js-nightlies-with-chrome-devtools-7c4a1b95ae27

@tlightsky
Copy link
Author

thanks, I shall upgrade my node to new version first

@fonghou
Copy link

fonghou commented Jan 19, 2017

I just tried it in node 7.4.0 and dirac 1.0.0.

Devtool console prints out a message "Feature :repl cannot be installed. Unsupported browser ."

Here is a screenshot with more details.

screen shot 2017-01-19 at 5 36 46 pm

My guess is that node doesn't has certain browser properties that dirac depends on (btw, cljs devtools also failed to install, above is with cljs devtools feature disabled)

@darwin
Copy link
Member

darwin commented Jan 19, 2017

we will have to relax this condition:

(and (ua/isChrome) (ua/isVersionOrHigher 47))) ; Chrome 47+

you might try to patch this function and then call dirac.runtime/install! by hand

@fonghou
Copy link

fonghou commented Jan 20, 2017

@darwin Thanks for the hint!

Hit another dependence on js/document. It looks like part of dirac client code has to be injected into chrome-devtools://devtools/bundled/inspector.html ?

Screenshot

screen shot 2017-01-19 at 7 26 11 pm

@darwin
Copy link
Member

darwin commented Jan 20, 2017

ok, set *boostrapped?* to true prior install! call:

(def ^:dynamic *boostrapped?* false)

after install call (brepl/bootstrap) by hand

let's see how far you can get...

@darwin
Copy link
Member

darwin commented Jan 20, 2017

ah, scratch my previous comment, I don't have time to reply now. Maybe you could figure out another way how to implement install! on your own. Maybe set! *boostrapped?* and *installed? to true and call (brepl/bootstrap)

@fonghou
Copy link

fonghou commented Jan 20, 2017

That didn't allow me to do what you suggested. Instead, I tried to comment out

(call-after-document-finished-loading boostrap-if-needed! 0)))

then call (boostrap-if-needed!) by hand. No error in js console, but dirac console won't start after clicking the button on toolbar.

screen shot 2017-01-19 at 8 04 50 pm

screen shot 2017-01-19 at 8 03 07 pm

@darwin
Copy link
Member

darwin commented Jan 21, 2017

I was able to make it work here on my Mac. But it will require some deeper changes. I'm pretty confident I will be able to provide an example project configuration by the end of this weekend.

@fonghou
Copy link

fonghou commented Jan 21, 2017

That's awesome! Looking forward to try it!

Really appreciate your time and effort in developing dirac!

darwin added a commit that referenced this issue Jan 22, 2017
darwin added a commit that referenced this issue Jan 22, 2017
@darwin darwin changed the title can dirac connect to my repl in nodejs(cljs) Node.js support Jan 22, 2017
@darwin
Copy link
Member

darwin commented Jan 22, 2017

Try to upgrade to v1.1.0, basic support should be in place:
https://github.com/binaryage/dirac/releases/tag/v1.1.0

@fonghou
Copy link

fonghou commented Jan 23, 2017

Hi @darwin, I did a quick test (not setting up external source-map serving yet). Basic feature works. Just want to let you know a few differences.

  1. you said in the doc, REPL eval only works at debugger point. However, my dirac repl seems working even not at debugger point.

  2. i got CLJS DevTools errors when Dirac hits a debugger point.

screen shot 2017-01-22 at 8 08 34 pm

@darwin
Copy link
Member

darwin commented Jan 23, 2017

Ok, thanks for the feedback. I'm not sure about that REPL eval. Could have been some glitch in my setup.

That CLJS DevTools Error is unrelated to this issue. It is not even CLJS devtools bug. You are likely to see similar stack trace event without cljs-devtools. It looks to me that Promesa throws when someone wants to print its value via IPrintWithWriter protocol.

@fonghou
Copy link

fonghou commented Jan 23, 2017

Yes, you are right. That's an issue from promesa. will report it there (i did a local fix that works).

Thanks again for your help!

@darwin
Copy link
Member

darwin commented Jan 31, 2017

Released in v1.1.0.

I don't hear any complaints. Feel free to reopen in case of bug reports.

@darwin darwin closed this as completed Jan 31, 2017
@fonghou
Copy link

fonghou commented May 7, 2017

This is with dirac node support. Getting

Internal Dirac Error Request Debugger.getPossibleBreakpoints failed. {"code":-32601,"message":"'Debugger.getPossibleBreakpoints' wasn't found"}

It seems triggered asynchronously, as well as when stepping in debugger. Please see sreenshot attached.

screen shot 2017-05-07 at 5 35 25 pm

@darwin
Copy link
Member

darwin commented May 7, 2017

This looks like out-of-sync debugger protocol between Devtools and Node.js.

In case of similar troubles, you should be using nightly builds of node.js:
https://github.com/binaryage/dirac/blob/master/docs/node.md#nodejs-version

@fonghou
Copy link

fonghou commented May 8, 2017

Yes, that seems the case. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants