diff --git a/src/node_contextify.cc b/src/node_contextify.cc index ed552ddd559f51..f37e95497c48c9 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_contextual_store || 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..a0dfbac7b8b10b --- /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.strictEqual(global[totoSymbol], 4); +assert.ok(Object.getOwnPropertySymbols(global).includes(totoSymbol));