-
Notifications
You must be signed in to change notification settings - Fork 56
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 client does not properly wait for async functions when code pasted in #356
Comments
I am also seeing this behavior if I try to .load code, so it doesn't seem to be directly related to copy/paste:
|
I tested it on OS/X and did not reproduce. What is your OS? |
I have been able to reproduce it both on OS X and Windows (Ubuntu subsystem). |
I tested with node 6.10.1. I tried with: function foo(_, val) { setTimeout(_, 10); return val; }
var x = foo(_, "abc")
console.log(x) On the other hand I got an error when hitting on an empty line. |
I did the copy paste several times and did not watch carefully. Actually, I see the problem the first time! |
I've fixed the node 6 issue with empty lines but I haven't fixed this one. This issue may be hard to fix because of the way REPL variables are managed. |
I'm testing some code by copy/pasting from an editor into _node. What I am finding is that when I do this, code on one line does not finish executing before _node tries to run the next command.
Here is a simple example in action. First, I initialize a small sqlite3 database:
Now I exit and restart _node and paste in the following code:
Since the call to db.all is streamlined, I would expect the variable "x" to have a value before the next line. However, here is the actual output:
The text was updated successfully, but these errors were encountered: