Open
Description
Consider the following code:
// Please note only Node.js code is supported here
async function run(msg, cfg, snapshot) {
console.log('Hello code, incoming message is msg=%j', msg);
let s = "abc";
let buff = Buffer.from(s);
let base64data = buff.toString('base64');
// Create message to be emitted
var data = messages.newMessageWithBody({message: base64data});
// Emit the data event
emitter.emit('data', data);
// No need to emit end
console.log('Finished execution');
}
One would expect it to produce a message {message: 'YWJj'}
. However, instead it produces
ReferenceError: Buffer is not defined
at evalmachine.<anonymous>:8:12
at ContextifyScript.Script.runInContext (vm.js:32:29)
at Object.runInContext (vm.js:87:6)
because we forgot to bring Buffer
and some other Node globals into the context in which the code is executed.
Metadata
Metadata
Assignees
Labels
No labels