I'm writing an application which needs to run code provided by users. The previous iteration was using VM2. To allow the users to debug what is going on in the backend, the previous iteration overrode console.log and funneled that to the frontend.
However I do not seem to be able to do this in webworker-threads.
Minimally reproducible case:
const Worker = require('webworker-threads').Worker;
let worker = new Worker(()=>{
let log = console.log;
console.log = (msg) => log('Hello '+msg);
self.onmessage = (evt) => console.log(evt.data);
});
worker.postMessage('Nick');
Expected output:
Hello Nick
Actual output:
Nick
I'm running the latest LTS version of node (I belive it's v6.11.2)
Hi there,
I'm writing an application which needs to run code provided by users. The previous iteration was using VM2. To allow the users to debug what is going on in the backend, the previous iteration overrode console.log and funneled that to the frontend.
However I do not seem to be able to do this in webworker-threads.
Minimally reproducible case:
Expected output:
Hello Nick
Actual output:
Nick
I'm running the latest LTS version of node (I belive it's v6.11.2)