-
-
Notifications
You must be signed in to change notification settings - Fork 35.2k
Description
- Version: v9.1.0
- Platform: Darwin XXXX 17.2.0 Darwin Kernel Version 17.2.0: Fri Sep 29 18:27:05 PDT 2017; root:xnu-4570.20.62~3/RELEASE_X86_64 x86_64
- Subsystem: OSX 10.13.1
Using a fresh install of Node 9.1.0, with no global packages or local dependencies. I use NVM to manage node.
I am testing algorithms and trying out Node's new REPL module, attaching properties to the context at the end of my file as follows:
repl.start().context = {
Bst: Bst,
myBst: myBst
}
When I try to access either of these properties, I get an error:
TypeError: sandbox argument must have been converted to a context.
at ContextifyScript.Script.runInContext (vm.js:59:29)
at REPLServer.defaultEval (repl.js:244:29)
at bound (domain.js:280:14)
at REPLServer.runBound [as eval] (domain.js:293:12)
at REPLServer.onLine (repl.js:493:10)
at emitOne (events.js:125:13)
at REPLServer.emit (events.js:221:7)
at REPLServer.Interface._onLine (readline.js:287:10)
at REPLServer.Interface._line (readline.js:642:8)
at REPLServer.Interface._ttyWrite (readline.js:922:14)
If I add just one property using dot notation repl.start().context.Bst = Bst then I can access that property. As an aside, I naively tried writing the following code with rather unexpected results:
repl.start().context.Bst = Bst
repl.start().context.myBst = myBst
If you run this code, two REPL servers will try and output to your shell at the same time, so every letter you type is typed twice, every command responded to (identically) twice. It's definitely two servers because incrementing a test variable will not increment it by 2, but display twice that the same variable has been incremented by 1 with the same result.