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

SyntaxError: Unexpected token #625

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

Comments

Projects
None yet
3 participants
@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

This comment has been minimized.

Show comment
Hide comment
@mooyoul

mooyoul Dec 28, 2016

Collaborator

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 :)

Collaborator

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

This comment has been minimized.

Show comment
Hide comment
@tj

tj Dec 28, 2016

Member

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.

Member

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 join this conversation on GitHub. Already have an account? Sign in to comment