skeeto / skewer-mode

Live web development in Emacs
The Unlicense
1.1k stars 57 forks source link

REPL hangs #28

Closed drudru closed 11 years ago

drudru commented 11 years ago

Hi,

I saw the video demo of skewer recently and it looks like an awesome tool. I'm having a strange issue.

I run-skewer then I run a skewer-repl. I have it configured to open a new tab in chrome vs. use my default browser.

When I type in the repl: document or x = 1

then it just hangs....

In another buffer I list the skewer clients and the emacs processes. Those look fine. The repl is in 'run', though. I even put a breakpoint on the skewer 'js' to see what messages were coming across. If I hit 'g' in the list-skewer-clients buffer, I will see a 'ping' come across, and I then continue from the break so the browser sends the pong back. This can occur while the repl is in the 'hung' state. I can even do a skewer.log() on the client browser and see the result come back to the emacs repl.

I don't see any errors in the chrome developer console.

There just doesn't seem to be a connection going from the repl to the browser.

Also, When I tested on an IOS simulator, it was working. In that instance, I injected skewer via a script tag. I put this out there as a weak argument as I haven't retested this.

Strange.

What should I do to diagnose this?

skeeto commented 11 years ago

Hmm, so you say the browser is listed by list-skewer-clients and continues to be listed after hitting g. When g is hit to refresh, it sends a ping to all clients and then assumes they're disconnected until they respond back. You said you saw the response, and the browser continues to be listed, so it's alive. Plus skewer.log() still works.

Can you evaluate expressions in a js2-mode buffer with skewer-mode enabled? I'm guessing that probably works.

Could you check for anything unusual in your *httpd* buffer? There might be an error mentioned. If not, could you try to fish out from the *httpd* logs what data the browser sent to Emacs as a response? Right now I'm guessing that something is going wrong in the skewer-post-repl callback. This is called by simple-httpd which suppresses any errors and logs them to *httpd*. The browser might be throwing something unexpected back to Emacs.

What version of Chrome on what OS is this? So far I'm unable to duplicate this myself.

drudru commented 11 years ago

One note. I didn't have js2 installed and therefore any js2 buffers open. I was just testing the repl. Just wanted to throw that in there before diving in to your suggestions.

drudru commented 11 years ago

Actually, I do have js2 installed.

drudru commented 11 years ago

I figured it out.

It hangs when I'm in viper-mode :-)

drudru commented 11 years ago

Actually, not sure if that was it now. Went over to the big app that I'm trying to debug and it hung again.

drudru commented 11 years ago

I checked the client side and ran a javascript profile. It looks like the browser is spending 99.9% time in skewer safe stringify.

drudru commented 11 years ago

Ok, yep, the problem is in safeStringify. It is caught in an endless loop and that is what is hanging the browser.

drudru commented 11 years ago

You may or may not be able to repro this. All I did was try to have the browser display 'document'. On a plain browser when skewer is started, this works fine. It does take a small pause, but it works. It returns: [object HTMLDocument]

I believe there must be something in one of the javascript libraries (google charts, jquery, d3, etc) on the other web page that is causing the trouble. Its kind of funny since it is doing all this work in stringify, yet would probably just return: [object HTMLDocument]

skeeto commented 11 years ago

I think fca1ccc might fix this. When safeStringify sees a DOM element, it doesn't waste time trying to stringify it since it ultimately can't.

drudru commented 11 years ago

Hi, yep, this fixed the issue! Thanks!