Skip to content

Shell treats SyntaxError thrown by user code as an unfinished command #8290

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

Closed
mattmccutchen opened this issue Jan 25, 2017 · 7 comments
Closed

Comments

@mattmccutchen
Copy link
Contributor

mattmccutchen commented Jan 25, 2017

When checking for a SyntaxError that indicates an unfinished command, the shell does not distinguish between SyntaxErrors from parsing the command and SyntaxErrors thrown by user code during the execution. Example:

$ meteor create --bare .  # currently using METEOR@1.4.2.3
[...]
$ meteor npm install
[...]
$ meteor npm install --save babel-runtime
[...]
$ meteor

In another terminal:

$ meteor shell

Welcome to the server-side interactive shell!

Tab completion is enabled for global variables.

Type .reload to restart the server and the shell.
Type .exit to disconnect from the server and leave the shell.
Type .help for additional help.

> JSON.parse("[")
... 

Once this happens, typically the only way to recover is to interrupt and restart the shell. This happened when I was debugging my application and was pretty confusing until I added a catch block to the shell command. (Of course, the JSON.parse("[") was happening inside a lot of other code.)

@abernix
Copy link
Contributor

abernix commented Jan 26, 2017

Hmm, In attempting to reproduce, I'm dropped to the ... (continuation) prompt in the same way as you demonstrate here, but when I press Ctrl+C, I'm returned to an active > prompt. Am I missing something?

@mattmccutchen
Copy link
Contributor Author

when I press Ctrl+C, I'm returned to an active > prompt.

You're right. I must not have tried this. So there's an easy recovery. The behavior is still confusing; I originally hit this with a longer command and was looking for the missing closing delimiter for a minute or two.

@abernix
Copy link
Contributor

abernix commented Jan 26, 2017

Yeah, the node REPL doesn't do this, but instead provides an more expected:

SyntaxError: Unexpected end of input

It could be getting caught (catch) in a number of places. Would need more investigation to figure it out specifically, but shell-server and shell-client code would be a place to start.

@benjamn
Copy link
Contributor

benjamn commented Feb 10, 2017

Can this be fixed with an update to the shell-server package, or do we need to update the client (i.e. meteor-tool)?

@abernix
Copy link
Contributor

abernix commented Feb 17, 2017

I had reason to believe it was a client-side fix, but I hadn't got the chance to investigate/debug.

@mattmccutchen If you get a chance to look into this, please let us know! Happy to help in the debugging process if you need assistance!

@mattmccutchen
Copy link
Contributor Author

This turned out to be an easy server-side fix: #8446.

mattmccutchen added a commit to mattmccutchen/meteor that referenced this issue Mar 2, 2017
Apply the check for a SyntaxError indicating an incomplete command only
to the ECMAScript translation and parsing of a command and not to the
execution, following the example of Node's defaultEval function.

Fixes meteor#8290.
abernix pushed a commit that referenced this issue Mar 9, 2017
Apply the check for a SyntaxError indicating an incomplete command only
to the ECMAScript translation and parsing of a command and not to the
execution, following the example of Node's defaultEval function.

Fixes #8290.
@abernix abernix added this to the Release 1.4.3.x milestone Mar 9, 2017
@abernix
Copy link
Contributor

abernix commented Mar 9, 2017

This should be fixed in Meteor 1.4.3.2. You can try the latest 1.4.3.2 beta and help confirm by running:

meteor update --release 1.4.3.2-beta.0

Please report back if you encounter any problems, and thanks for reporting and taking care of this!

@abernix abernix modified the milestones: Release 1.4.3.x, Release 1.4.3.2 Mar 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants