mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
4bd410bbbe
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>
27 lines
517 B
JavaScript
27 lines
517 B
JavaScript
'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);
|