diff --git a/src/node_contextify.cc b/src/node_contextify.cc index ed552ddd559f51..fdab91714d7da0 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -530,7 +530,9 @@ void ContextifyContext::PropertySetterCallback( return; USE(ctx->sandbox()->Set(context, property, value)); - args.GetReturnValue().Set(value); + if (is_function) { + args.GetReturnValue().Set(value); + } } // static diff --git a/test/parallel/test-vm-global-symbol.js b/test/parallel/test-vm-global-symbol.js new file mode 100644 index 00000000000000..72ca935cd82438 --- /dev/null +++ b/test/parallel/test-vm-global-symbol.js @@ -0,0 +1,15 @@ +'use strict'; +require('../common'); +const assert = require('assert'); +const vm = require('vm'); + +const global = vm.runInContext('this', vm.createContext()); +const totoSymbol = Symbol.for('toto'); +Object.defineProperty(global, totoSymbol, { + enumerable: true, + writable: true, + value: 4, + configurable: true, +}); +assert.ok(global[totoSymbol] === 4); +assert.ok(Object.getOwnPropertySymbols(global).includes(totoSymbol));