From 4574593664cc4aaab167ef477389b5e88f5baa8f Mon Sep 17 00:00:00 2001 From: Asher Date: Tue, 10 Nov 2020 18:20:44 -0600 Subject: [PATCH] Refactor vscode init to use async Hopefully is a bit easier to read. --- src/node/routes/vscode.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/node/routes/vscode.ts b/src/node/routes/vscode.ts index 55200127..9b464f61 100644 --- a/src/node/routes/vscode.ts +++ b/src/node/routes/vscode.ts @@ -22,18 +22,14 @@ router.get("/", async (req, res) => { const [content, options] = await Promise.all([ await fs.readFile(path.join(rootPath, "src/browser/pages/vscode.html"), "utf8"), - vscode - .initialize( - { - args: req.args, - remoteAuthority: req.headers.host || "", - }, - req.query, - ) - .catch((error) => { + (async () => { + try { + return await vscode.initialize({ args: req.args, remoteAuthority: req.headers.host || "" }, req.query) + } catch (error) { const devMessage = commit === "development" ? "It might not have finished compiling." : "" throw new Error(`VS Code failed to load. ${devMessage} ${error.message}`) - }), + } + })(), ]) options.productConfiguration.codeServerVersion = version