Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Unexpected end of input #238

Closed
bpaczkowski opened this issue Mar 21, 2016 · 18 comments
Closed

Unexpected end of input #238

bpaczkowski opened this issue Mar 21, 2016 · 18 comments
Labels

Comments

@bpaczkowski
Copy link

I'm getting this error when linter tries to parse a file.

[Linter-JSHint] SyntaxError: Unexpected end of input
at Object.parse (native)
at Object.<anonymous> (C:/Users/Bartek/.atom/packages/linter-jshint/lib/main.js:116:25)
at [object Generator].next (native)
at step (C:\Users\Bartek\.atom\packages\linter-jshint\lib\main.js:3:273)

#115 might be related, but that was on Mac, I'm running Windows 10, and path seems to be set correctly:

process.env.Path
"C:\Python27\;C:\Python27\Scripts;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\nodejs\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\cmd;C:\Users\Bartek\AppData\Roaming\npm;C:\Users\Bartek\AppData\Local\atom\bin"

I tried to debug this and with my limited knowledge of node I gathered this: this.executablePath in call to Helpers.execNode doesn't seem to be set at all, which results in empty result. But even replacing this.executablePath with the exact location of JSHint doesn't seem to work as well and result is still empty.

@Arcanemagus
Copy link
Member

That's being set here, if you put a breakpoint there and disable/enable the package are you seeing a reasonable value there? You should see the default value (defined here) unless you have customized it to something else.

@bpaczkowski
Copy link
Author

Yes, I get a default value of "C:\Users\Bartek\.atom\packages\linter-jshint\node_modules\jshint\bin\jshint", but a breakpoint here shows it as undefined. Even if I set it manually in the package settings it's still undefined.

@Arcanemagus
Copy link
Member

Ah, this is a babel-ified file, it's going to be something like _this2 in the first Closure:
image

If you step into the function call (F11) you can see that command should be set properly. It looks like it's returning "" for me as well though so something is wrong...

@chriscasola
Copy link

I'm also seeing this problem. This is on windows 7, but only when I launch using the Atom desktop shortcut. If I launch atom at the command line everything works fine.

When I launch with the shortcut, I can step in and see the exec call here timing out. But it times out after the await returns, so this line ends up trying to parse an empty string.

The command and arguments to the exec call look correct in both environments.

I'm not too familiar with how exec works in atom, but let me know if I can try anything else or provide more info.

@danshapir
Copy link

Same issue with Windows 10. Each lint fails with

[Linter-JSHint] SyntaxError: Unexpected end of input(…) 
(anonymous function)    @   /C:/Users/dansh/.atom/packages/linter-jshint/lib/main.js:115

That's the

parsed = JSON.parse(result)

@Arcanemagus
Copy link
Member

An update:
Looks like this is a Windows only bug, I've tested v1.5.4, v1.6.0, and 1.8.0-dev-307944c on Ubuntu with no issue.

@rodrigo-md
Copy link

I had this problem today and it was the .jshintrc was empty. After adding some options went smoothly.

@danshapir
Copy link

@rodrigo-martinezd Tried, didn't work for me...

@emileber
Copy link

It seems to be a problem with Atom versions over 1.7 on windows. Myself and a coworker had the issue with version 1.7.0-beta5 and I reverted back to the version I had before, which is 1.5.0-beta3 and my coworker tried 1.6.2 without issue.

@sirlancelot
Copy link

I'm on Windows 10. Atom just updated to 1.7 and I'm seeing this issue when I edit JS files. I have a valid .jshintrc file and didn't see this error in Atom 1.6.2.

Tracking it down it looks like execNode is returning an empty string instead of the JSON string of the JSHint results. Unfortunately, I can't find more detail since I don't know how to step in to execNode with the debugger...

@Arcanemagus
Copy link
Member

I've stepped as far down as Atom's BufferedProcess, for some reason only for jscs we are getting no data back on the stdout stream. I'm not really sure where to debug from here yet and haven't had time to try anything else yet.

@Arcanemagus Arcanemagus mentioned this issue Apr 14, 2016
@Arcanemagus
Copy link
Member

@craigbuckler pointed out something explicitly over in #257 which was mentioned off hand here but I didn't catch: It looks like this might have started with the v1.7.0 update.

@Arcanemagus
Copy link
Member

Just an update, we've confirmed that this must be a bug in the internal version of Electron inside Atom. If you replace process.execPath with a local Node install everything works as expected with no other changes.

@Arcanemagus
Copy link
Member

Filed atom/atom#11471 as it looks to be the Electron bundled within Atom that is the root cause of this.

@benoitcerrina
Copy link

Based on your comment about process.execPath,
I have locally modified the code the following way

    var oldExecPath = process.execPath;
    process.execPath = "E:\\Program Files\\nodejs\\node.exe"
    const result = await Helpers.execNode(
      this.executablePath, parameters, { stdin: fileContents }
    )
    process.execPath = oldExecPath;

It seems to fix it, however as I am very unfamiliar with atom in particular and node in general I am worried about potential impacts (because the call is asynchronous and is using await, the process.execPath is not restored immediately.

Do you think that is a workable fix while waiting for the atom bug to be resolved?

@Arcanemagus
Copy link
Member

You might be safer installing v1.6.2 and disabling auto updates, as I don't know all the impacts of overwriting that either.

You would need to watch for updates to Atom though to catch when this gets fixed on your own after doing that.

@benoitcerrina
Copy link

thanks for the reply

@Arcanemagus
Copy link
Member

Atom v1.7.1 (And v1.8.0-beta1) has been released which should fix this. If you are still having issues please re-open this or file a new issue.

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

No branches or pull requests

8 participants