JunoLab / atom-julia-client

Juno a good IDE?
http://junolab.org
MIT License
272 stars 72 forks source link

Uncaught SyntaxError: Unexpected token [ #19

Closed ssfrr closed 9 years ago

ssfrr commented 9 years ago

To Reproduce:

  1. Open a Julia file in a fresh atom
  2. run the julia-client "toggle console" command
  3. type 1+1 in the console and press enter
  4. While that's chugging away move the cursor around a few times by clicking inside the Julia file
  5. Bang. Exception.

When I run that sequence with a breakpoint on tcp.coffee:12 I see the first time it's called everything is fine (at least it doesn't thrown an exception), but the 2nd time str ends up with the value

"[3,{"inactive":false,"sub":"AudioIO","subInactive":true,"main":"Main"}]["result",{"error":false,"result":"2"}]

[1,null]
"

So then lines ends up being a 5-element array with some empty strings and the first element had two JSON lists that aren't newline separated. At this point buffer still has the first element of "[2,{"inactive":false,"sub":"AudioIO","subInactive":true,"main":"Main"}]" (the last item that got put in there?) So when it hits the code buffer[0] += lines.shift(), the first element of the buffer actually ends up having 3 JSON lists smushed up against each other. Then when it tries to call f on that string (which tries to parse it) then it throws the exception, probably on the opening bracket of the 2nd smushed message.

So as far as I can tell there are 2 bugs here:

  1. We're getting malformed data over the TCP string, possibly from interleaved tasks on the Julia side (total guess)
  2. when the receiver task gets called on the Atom side, there is sometimes still data in the first element of the buffer, so the incoming data just gets appended to it

I think after the first exception gets called here, buffer is hosed and has empty strings in it, which is what then causes #18.

Atom Version: 1.0.11 System: Mac OS X 10.10.4 Thrown From: julia-client package, v0.1.2

Stack Trace

Uncaught SyntaxError: Unexpected token [

At file:///Applications/Atom.app/Contents/Resources/app.asar/static/index.html#%7B%22locationsToOpen%22%3A%5B%7B%22pathToOpen%22%3A%22%2FUsers%2Fsrussell%2F.julia%2Fv0.4%2FAudioIO%22%7D%5D%2C%22bootstrapScript%22%3A%22%2FApplications%2FAtom.app%2FContents%2FResources%2Fapp.asar%2Fsrc%2Fwindow-bootstrap.js%22%2C%22resourcePath%22%3A%22%2FApplications%2FAtom.app%2FContents%2FResources%2Fapp.asar%22%2C%22devMode%22%3Afalse%2C%22safeMode%22%3Afalse%2C%22appVersion%22%3A%221.0.11%22%2C%22shellLoadTime%22%3A984%2C%22initialPaths%22%3A%5B%22%2FUsers%2Fsrussell%2F.julia%2Fv0.4%2FAudioIO%22%5D%7D:1

SyntaxError: Unexpected token [
  at Object.parse (native)
  at /Users/srussell/dotfiles/.atom/packages/julia-client/lib/connection/tcp.coffee:36:27
  at Socket.<anonymous> (/Users/srussell/dotfiles/.atom/packages/julia-client/lib/connection/tcp.coffee:17:9)
  at emitOne (events.js:77:13)
  at Socket.emit (events.js:166:7)
  at readableAddChunk (_stream_readable.js:146:16)
  at Socket.Readable.push (_stream_readable.js:109:10)
  at TCP.onread (net.js:517:20)

Commands

     -0:27.1.0 command-palette:toggle (atom-text-editor.editor.vim-mode.normal-mode.is-focused)
  6x -0:22.6.0 core:move-down (atom-text-editor.editor.mini.is-focused)
     -0:21.4.0 core:confirm (atom-text-editor.editor.mini.is-focused)
     -0:21.3.0 julia-client:toggle-console (atom-text-editor.editor.vim-mode.normal-mode)
     -0:16.9.0 console:evaluate (atom-text-editor.editor.is-focused)
     -0:16.9.0 julia-client:start-julia (atom-workspace.workspace.scrollbars-visible-when-scrolling.theme-one-dark-syntax.theme-one-dark-ui)

Config

{
  "core": {},
  "julia-client": {
    "juliaPath": "/usr/local/bin/julia4"
  }
}

Installed Packages

# User
atom-yeoman, v0.3.13
autocomplete-bibtex, v0.6.1
autocomplete-clang, v0.8.7
autocomplete-julia, v0.1.0
build-tools, v3.7.0
ink, v0.1.1
json-schema, v0.1.13
julia-client, v0.1.2
language-cmake, v0.1.4
language-julia, v0.4.1
language-latex, v0.6.1
latex-completions, v0.3.0
linter, v1.5.0
markdown-preview-katex, v0.3.4
markdown-scroll-sync, v0.4.2
minimap, v4.13.2
pdf-view, v0.23.0
vim-mode, v0.59.0
vim-surround, v0.8.0
wordcount, v2.3.0
zentabs, v0.8.6

# Dev
No dev packages
davidanthoff commented 9 years ago

I get this as well. I updated my julia 0.4 build today, didn't see this error before that. I don't know which build of 0.4 I had installed previously. I'm on Windows.

pfitzseb commented 9 years ago

Yeah, me too. Also on Windows. And this definitely is a regression, but I'm not sure that it really was because of updating julia -- I got the error after updating Julia, Atom.jl and atom-julia-client... Did you update any packages/Juno or only Julia, @davidanthoff?

davidanthoff commented 9 years ago

I can't tell anymore, I probably updated other things as well...

nilshg commented 9 years ago

I think for me it was just Julia; I still have a 10-day old 0.4-dev master installed on my main machine (won't touch it as it's currently running perfectly and I have a PhD thesis to submit in <4 weeks!) and there are no errors, although Atom.jl, julia-client and ink are up-to-date (I believe).

My main machine is Win7, my Surface (that produces both this error and the closed #6) runs on Win10.

pfitzseb commented 9 years ago

I'm not seeing this anymore (and didn't update Julia). Did you fix this, @one-more-minute?

nilshg commented 9 years ago

I agree, this seems to be fixed on my Surface (with Julia, Atom, Atom.jl and dependencies all up to date) as well. Close this issue?

MikeInnes commented 9 years ago

Yup, this was fixed with @ssfrr's JunoLab/Atom.jl#3. Julia master should fix the upstream issue as well, as it happens, although I haven't tested that yet.