Skip to content

Instantly share code, notes, and snippets.

@jugglinmike
Created July 26, 2017 19:20
Show Gist options
  • Save jugglinmike/a5addcc691bc688c519b231a81ae99af to your computer and use it in GitHub Desktop.
Save jugglinmike/a5addcc691bc688c519b231a81ae99af to your computer and use it in GitHub Desktop.
TypeError from VM context
//vm.createContext({console});
vm.runInThisContext(`
Object.defineProperty(Object.prototype, "length", {
get: function () {
return 1;
},
configurable: true
});
`);
/**
* The following function call produces a TypeError, but the error does not
* occur if the `console` object has previously been "contextified" (as in the
* first line of this file))
*
* internal/streams/BufferList.js:10
* this.length = 0;
*
*
* TypeError: Cannot set property length of #<Object> which has only a getter
* at new BufferList (internal/streams/BufferList.js:10:15)
* at new ReadableState (_stream_readable.js:57:17)
* at WriteStream.Readable (_stream_readable.js:108:25)
* at WriteStream.Duplex (_stream_duplex.js:27:12)
* at WriteStream.Socket (net.js:139:17)
* at new WriteStream (tty.js:45:14)
* at createWritableStdioStream (internal/process/stdio.js:143:16)
* at process.getStdout [as stdout] (internal/process/stdio.js:10:14)
* at console.js:100:37
* at NativeModule.compile (bootstrap_node.js:493:7)
*/
console.log('');
// Node v6.10.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment