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 Module Error (newline-json\parser.js) #44

Closed
CodingButter opened this issue Aug 27, 2016 · 11 comments
Closed

Node Module Error (newline-json\parser.js) #44

CodingButter opened this issue Aug 27, 2016 · 11 comments

Comments

@CodingButter
Copy link

It seams like there is a error within one of the dependencies. I'm not sure if this is just a windows problem.

events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: Unexpected end of JSON input in "\n\"starting\"\n"
    at Parser._transform (G:\btproject\node_modules\newline-json\parser.js:30:12)
    at Parser.Transform._read (_stream_transform.js:167:10)
    at Parser.Transform._write (_stream_transform.js:155:12)
    at doWrite (_stream_writable.js:307:12)
    at writeOrBuffer (_stream_writable.js:293:5)
    at Parser.Writable.write (_stream_writable.js:220:11)
    at Socket.ondata (_stream_readable.js:556:20)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:177:18)
@ipsBruno
Copy link

Same error here.

Aparrently, is problem of new-linejson

mappum/electron-eval#50

@mappum @feross

@mappum
Copy link
Member

mappum commented Aug 27, 2016

It appears both occurrences have happened on Windows. Also, newline-json gives that error if the data begins with \n, so we just have to find where that newline is coming from.

@CodingButter
Copy link
Author

parse.js
commenting out lines 30 and 31 are a band-aid let me know if helps you

@ipsBruno
Copy link

I already try commenting out line. But don't still work here.

@mappum
Copy link
Member

mappum commented Aug 27, 2016

That newline-json stream is receiving the stdout output of the Electron child process. So I think we will just have to ensure we consume the first byte (\n) of the stdout stream when using Windows (although it sucks that we have to).

@CodingButter
Copy link
Author

why is windows the problem?

@mappum
Copy link
Member

mappum commented Aug 27, 2016

Can you guys test with electron-eval on this branch: https://github.com/mappum/electron-eval/tree/newline-fix?

@ipsBruno
Copy link

Nothing here.

I made all changes.

https://github.com/mappum/electron-eval/compare/newline-fix

And still show error here.

@ipsBruno
Copy link

ipsBruno commented Aug 27, 2016

I try with this:

   this.child.stdout.once('data', (data) => {
      // this hack fixes issues where some environments (namely Windows)
      // prepend a '\n' at the beginning of the stdout stream. This breaks
      // the JSON parser, so if the stream starts with '\n' we skip it
      while(true){
            var dec = data.toString().charCodeAt(0) ;

            if(dec != 13 && dec != 10) break;
            data = data.slice(1, data.length)
      }

      this.stdout.write(data)
      this.child.stdout.pipe(this.stdout)

    })

This aparently work here. Optimize my code, please.

Basicaly you need a left trim function in data array ..

Sorry my english. Thank you

@mappum
Copy link
Member

mappum commented Aug 28, 2016

This should be fixed as of electron-eval@0.9.3. Can you guys reinstall and confirm that the issue is fixed?

@feross
Copy link
Member

feross commented Sep 11, 2016

Just tested on Windows. This looks fixed to me. Thanks @mappum.

@feross feross closed this as completed Sep 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants