Skip to content
This repository has been archived by the owner on Jan 1, 2025. It is now read-only.

readline as script in vm2 throws error on keyDown #7

Closed
minecrawler opened this issue Apr 13, 2015 · 1 comment
Closed

readline as script in vm2 throws error on keyDown #7

minecrawler opened this issue Apr 13, 2015 · 1 comment

Comments

@minecrawler
Copy link

I try to execute input from the commandline in a sandbox with vm2.
Unfortunately, after executing one command, I always get an error as soon as I press another key.

L:\tmp>node test.js
> console.log('Hellow World!');
Hellow World!
{}
> events.js:85
throw er; // Unhandled 'error' event
^
TypeError: Invalid non-string/buffer chunk
at chunkInvalid (_stream_readable.js:384:10)
at readableAddChunk (_stream_readable.js:140:12)
at ReadStream.Readable.push (_stream_readable.js:126:10)
at TTY.onread (net.js:538:20)

L:\tmp>

Test script:

'use strict';

var vm = require('vm2');
var readline = require('readline');

var rl = readline.createInterface({

    input: process.stdin,
    output: process.stdout
});

rl.setPrompt('> ');
rl.prompt();

rl.on('line', function ($line) {

    var options = {

        sandbox: {},
        console: 'inherit',
        language: 'javascript',
        require: true,
        requireNative: true,
        requireExternal: true,
    };

    var sb = new vm.NodeVM(options);


    console.log(sb.run($line));
    rl.prompt();
});

Versions:
vm2 - 0.2.2

http_parser - 2.3
node - 0.12.2
v8 - 3.28.73
uv - 1.4.2-node1
zlib - 1.2.8
modules - 14
openssl - 1.0.1m

@patriksimek
Copy link
Owner

Discussion moved to #22

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants