diff --git a/index.js b/index.js index 806727f..76b28fe 100644 --- a/index.js +++ b/index.js @@ -68,13 +68,15 @@ io.on('connection', (socket) => { resetVM() socket.on('runCode', (transactionId, code) => { - try { - const output = vm.run(code) + (async () => { + try { + const output = vm.run(code) - socket.emit('codeOutput', transactionId, false, util.inspect(output, { stylize })) - } catch (e) { - socket.emit('codeOutput', transactionId, true, e.toString()) - } + socket.emit('codeOutput', transactionId, false, util.inspect(output, { stylize })) + } catch (e) { + socket.emit('codeOutput', transactionId, true, e.toString()) + } + })() }) socket.on('reset', resetVM)