From 01ce593e96c2a2c70e7e1870acb66266f2b46e89 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Mon, 3 Sep 2018 13:49:58 +0200 Subject: [PATCH] improve error message and tell user to quit vscode first, #55675 --- src/vs/code/node/cli.ts | 58 ++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/src/vs/code/node/cli.ts b/src/vs/code/node/cli.ts index 041d2e9f00a..9316cc507d7 100644 --- a/src/vs/code/node/cli.ts +++ b/src/vs/code/node/cli.ts @@ -270,38 +270,42 @@ export async function main(argv: string[]): Promise { fs.writeFileSync(filenamePrefix, argv.slice(-6).join('|')); - processCallbacks.push(async child => { + processCallbacks.push(async _child => { + try { + // load and start profiler + const profiler = await import('v8-inspect-profiler'); + const main = await profiler.startProfiling({ port: portMain }); + const renderer = await profiler.startProfiling({ port: portRenderer, tries: 200 }); + const extHost = await profiler.startProfiling({ port: portExthost, tries: 300 }); - // load and start profiler - const profiler = await import('v8-inspect-profiler'); - const main = await profiler.startProfiling({ port: portMain }); - const renderer = await profiler.startProfiling({ port: portRenderer, tries: 200 }); - const extHost = await profiler.startProfiling({ port: portExthost, tries: 300 }); + // wait for the renderer to delete the + // marker file + whenDeleted(filenamePrefix); - // wait for the renderer to delete the - // marker file - whenDeleted(filenamePrefix); + let profileMain = await main.stop(); + let profileRenderer = await renderer.stop(); + let profileExtHost = await extHost.stop(); + let suffix = ''; - let profileMain = await main.stop(); - let profileRenderer = await renderer.stop(); - let profileExtHost = await extHost.stop(); - let suffix = ''; + if (!process.env['VSCODE_DEV']) { + // when running from a not-development-build we remove + // absolute filenames because we don't want to reveal anything + // about users. We also append the `.txt` suffix to make it + // easier to attach these files to GH issues + profileMain = profiler.rewriteAbsolutePaths(profileMain, 'piiRemoved'); + profileRenderer = profiler.rewriteAbsolutePaths(profileRenderer, 'piiRemoved'); + profileExtHost = profiler.rewriteAbsolutePaths(profileExtHost, 'piiRemoved'); + suffix = '.txt'; + } - if (!process.env['VSCODE_DEV']) { - // when running from a not-development-build we remove - // absolute filenames because we don't want to reveal anything - // about users. We also append the `.txt` suffix to make it - // easier to attach these files to GH issues - profileMain = profiler.rewriteAbsolutePaths(profileMain, 'piiRemoved'); - profileRenderer = profiler.rewriteAbsolutePaths(profileRenderer, 'piiRemoved'); - profileExtHost = profiler.rewriteAbsolutePaths(profileExtHost, 'piiRemoved'); - suffix = '.txt'; + // finally stop profiling and save profiles to disk + await profiler.writeProfile(profileMain, `${filenamePrefix}-main.cpuprofile${suffix}`); + await profiler.writeProfile(profileRenderer, `${filenamePrefix}-renderer.cpuprofile${suffix}`); + await profiler.writeProfile(profileExtHost, `${filenamePrefix}-exthost.cpuprofile${suffix}`); + + } catch (e) { + console.error('Failed to profile startup. Make sure to quit Code first.'); } - - // finally stop profiling and save profiles to disk - await profiler.writeProfile(profileMain, `${filenamePrefix}-main.cpuprofile${suffix}`); - await profiler.writeProfile(profileRenderer, `${filenamePrefix}-renderer.cpuprofile${suffix}`); - await profiler.writeProfile(profileExtHost, `${filenamePrefix}-exthost.cpuprofile${suffix}`); }); }