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

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

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

Comments

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

This comment has been minimized.

Member

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

This comment has been minimized.

Contributor

mattmccutchen commented Jan 26, 2017

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

This comment has been minimized.

Member

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

This comment has been minimized.

Member

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

This comment has been minimized.

Member

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 added a commit to mattmccutchen/meteor that referenced this issue Mar 2, 2017

Shell: Don't treat SyntaxError thrown by command execution as an unfi…
…nished command. (meteor#8290)

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.

mattmccutchen added a commit to mattmccutchen/meteor that referenced this issue Mar 2, 2017

Shell: Don't be confused by SyntaxErrors thrown by command execution.
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.
@mattmccutchen

This comment has been minimized.

Contributor

mattmccutchen commented Mar 2, 2017

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

Shell: Don't be confused by SyntaxErrors thrown by command execution.
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.

@benjamn benjamn closed this in #8446 Mar 8, 2017

abernix added a commit that referenced this issue Mar 9, 2017

Shell: Don't be confused by SyntaxErrors thrown by command execution.
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

This comment has been minimized.

Member

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