Skip to content
This repository has been archived by the owner. It is now read-only.

SyntaxError: Unexpected token #625

Closed
gurre opened this issue Dec 27, 2016 · 2 comments
Closed

SyntaxError: Unexpected token #625

gurre opened this issue Dec 27, 2016 · 2 comments
Labels

Comments

@gurre
Copy link

@gurre gurre commented Dec 27, 2016

  • Operating system: Darwin 15.6.0
  • Apex Version: Apex version 0.11.0

Im spawning a process inside of a Go-program. The output from the program produces an error within Apex.

Perhaps making the JS-shim more robust?

SyntaxError: Unexpected token G
    at Object.parse (native)
    at LineStream.exports.handle.ctx (/var/task/index.js:35:18)
    at LineStream.emit (events.js:95:17)
    at LineStream.<anonymous> (_stream_readable.js:765:14)
    at LineStream.emit (events.js:92:17)
    at emitReadable_ (_stream_readable.js:427:10)
    at emitReadable (_stream_readable.js:423:5)
    at readableAddChunk (_stream_readable.js:166:9)
    at LineStream.Readable.push (_stream_readable.js:128:10)
    at LineStream.Transform.push (_stream_transform.js:140:32)
@mooyoul
Copy link
Collaborator

@mooyoul mooyoul commented Dec 28, 2016

Note that stdout of Go program is reserved for the shim, and stdout of Go program should be print valid JSON. because communication between shim and Go program uses JSON.

Anyway, the reason why Node.js runtime throws error is Node.js runtime tried to parse G (blabla) text in JSON which is invalid JSON syntax. string values are will represented by wrapped double quotes.
For example, if you want to represent foo string in JSON, it should be "foo", not foo.

so If you spawn process from (shimmed) Go program, you should not pipe stdout of spawned process to stdout of your Go program writes if that spawned process doesn't print JSON :)

@tj
Copy link
Member

@tj tj commented Dec 28, 2016

Yeah the shim doesn't necessarily have to be stdio, but it is for now, definitely have to avoid using stdout from the Go program (most loggers etc log to stderr anyway). May change from stdio in the future but not any time soon.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.