mirror of https://github.com/lukechilds/node.git
Browse Source
Make less assumptions about what objects will be available when vm context creation or error message printing fail because V8 runs out of JS stack space. Ref: https://github.com/nodejs/node/issues/6899 PR-URL: https://github.com/nodejs/node/pull/6907 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>v7.x
3 changed files with 38 additions and 6 deletions
@ -0,0 +1,26 @@ |
|||||
|
'use strict'; |
||||
|
require('../common'); |
||||
|
const assert = require('assert'); |
||||
|
const vm = require('vm'); |
||||
|
|
||||
|
function a() { |
||||
|
try { |
||||
|
return a(); |
||||
|
} catch (e) { |
||||
|
// Throw an exception as near to the recursion-based RangeError as possible.
|
||||
|
return vm.runInThisContext('() => 42')(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
assert.strictEqual(a(), 42); |
||||
|
|
||||
|
function b() { |
||||
|
try { |
||||
|
return b(); |
||||
|
} catch (e) { |
||||
|
// This writes a lot of noise to stderr, but it still works.
|
||||
|
return vm.runInNewContext('() => 42')(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
assert.strictEqual(b(), 42); |
Loading…
Reference in new issue