diff --git a/index.js b/index.js index d8787ed..01873a0 100644 --- a/index.js +++ b/index.js @@ -71,13 +71,15 @@ io.on('connection', async (socket) => { resetVM() socket.on('runCode', async (transactionId, code) => { - try { - const output = vm.run(code) + new Promise(() => { + 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)