It seems this is because Buffer is non-enumerable, and we use Object.keys to merge global into sandbox, so Buffer gets left behind.
A few things like URL are being merged manually, perhaps the same could be done for Buffer?
Alternatively, we could use Object.getOwnPropertyNames(global) instead of Object.keys to avoid missing non-enumerable properties, though I don't know if this has any unintended side-effects. For now, I fixed it on my side by passing those as the scope (third argument).
Example (node v14.16.1):
It seems this is because Buffer is non-enumerable, and we use
Object.keys
to mergeglobal
intosandbox
, soBuffer
gets left behind.A few things like
URL
are being merged manually, perhaps the same could be done forBuffer
?Alternatively, we could use
Object.getOwnPropertyNames(global)
instead ofObject.keys
to avoid missing non-enumerable properties, though I don't know if this has any unintended side-effects. For now, I fixed it on my side by passing those as the scope (third argument).Thanks!