Open martian17 opened 2 years ago
Confirmed the problem on Ubuntu 20.04 node v16.15.0. Also confirmed that the same counter measure was effective (useGlobal: true
in repl.start()
for the first problem and removing /tmp/node-repl-sock
for the second problem)
In general, named UNIX sockets are not automatically removed from the file system.
Affected URL(s)
https://nodejs.org/docs/latest/api/repl.html
Description of the problem
Details
Under
Starting multiple REPL instances against a single running instance
there is a code that demonstrates the sharing of a single global object among multiple repl instances. However, the code in question does not work. That is, when I run this code and connect to it withtelnet localhost 5001
, the variable that I define in the telnet instance does not get reflected in the normal stdin/out instance. I found that this is most likely becauseuseGlobal
option is set tofalse
by default inrepl.start
, as explained in the same document. To enable this, I needed to explicitly set this totrue
inrepl.start
argument like this. Now the code works as expected.Also, there is a second but minor problem in this code. After I exit and try to execute the script again, the following error is thrown.
To get this to work again, I had to remove
/tmp/node-repl-sock
file from my laptop. I don't have a good idea on how Unix socket works, but I think there should be an additional cleanup process in the code.Here are my system info just for the reference.
Node.js version
v16.8.0
Operating system
macOS Mojave 10.14.6
I originally filed this issue on nodejs/help, but found out later that the main repo also accepts the docs issue, so I'm re-posting it here.