Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
bda5098e
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bda5098e
编写于
5月 28, 2019
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - restore previous async behaviour on startup
上级
84deb302
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
75 addition
and
67 deletion
+75
-67
src/vs/code/electron-main/main.ts
src/vs/code/electron-main/main.ts
+75
-67
未找到文件。
src/vs/code/electron-main/main.ts
浏览文件 @
bda5098e
...
...
@@ -38,6 +38,7 @@ import { BufferLogService } from 'vs/platform/log/common/bufferLog';
import
{
uploadLogs
}
from
'
vs/code/electron-main/logUploader
'
;
import
{
setUnexpectedErrorHandler
}
from
'
vs/base/common/errors
'
;
import
{
IThemeMainService
,
ThemeMainService
}
from
'
vs/platform/theme/electron-main/themeMainService
'
;
import
{
Client
}
from
'
vs/base/parts/ipc/common/ipc.net
'
;
class
ExpectedError
extends
Error
{
readonly
isExpected
=
true
;
...
...
@@ -63,6 +64,10 @@ function setupIPC(accessor: ServicesAccessor): Promise<Server> {
}
async
function
setup
(
retry
:
boolean
):
Promise
<
Server
>
{
// Try to setup a server for running. If that succeeds it means
// we are the first instance to startup. Otherwise it is likely
// that another instance is already running.
let
server
:
Server
;
try
{
server
=
await
serve
(
environmentService
.
mainIPCHandle
);
...
...
@@ -85,73 +90,12 @@ function setupIPC(accessor: ServicesAccessor): Promise<Server> {
}
// there's a running instance, let's connect to it
let
client
:
Client
<
string
>
;
try
{
const
client
=
await
connect
(
environmentService
.
mainIPCHandle
,
'
main
'
);
// Tests from CLI require to be the only instance currently
if
(
environmentService
.
extensionTestsLocationURI
&&
!
environmentService
.
debugExtensionHost
.
break
)
{
const
msg
=
'
Running extension tests from the command line is currently only supported if no other instance of Code is running.
'
;
logService
.
error
(
msg
);
client
.
dispose
();
throw
new
Error
(
msg
);
}
// Show a warning dialog after some timeout if it takes long to talk to the other instance
// Skip this if we are running with --wait where it is expected that we wait for a while.
// Also skip when gathering diagnostics (--status) which can take a longer time.
let
startupWarningDialogHandle
:
NodeJS
.
Timeout
|
undefined
=
undefined
;
if
(
!
environmentService
.
wait
&&
!
environmentService
.
status
&&
!
environmentService
.
args
[
'
upload-logs
'
])
{
startupWarningDialogHandle
=
setTimeout
(()
=>
{
showStartupWarningDialog
(
localize
(
'
secondInstanceNoResponse
'
,
"
Another instance of {0} is running but not responding
"
,
product
.
nameShort
),
localize
(
'
secondInstanceNoResponseDetail
'
,
"
Please close all other instances and try again.
"
)
);
},
10000
);
}
const
channel
=
client
.
getChannel
(
'
launch
'
);
const
service
=
new
LaunchChannelClient
(
channel
);
// Process Info
if
(
environmentService
.
args
.
status
)
{
return
instantiationService
.
invokeFunction
(
async
accessor
=>
{
const
diagnostics
=
await
accessor
.
get
(
IDiagnosticsService
).
getDiagnostics
(
service
);
console
.
log
(
diagnostics
);
throw
new
ExpectedError
();
});
}
// Log uploader
if
(
typeof
environmentService
.
args
[
'
upload-logs
'
]
!==
'
undefined
'
)
{
return
instantiationService
.
invokeFunction
(
async
accessor
=>
{
await
uploadLogs
(
service
,
accessor
.
get
(
IRequestService
),
environmentService
);
throw
new
ExpectedError
();
});
}
// Windows: allow to set foreground
if
(
platform
.
isWindows
)
{
await
windowsAllowSetForegroundWindow
(
service
);
}
// Send environment over...
logService
.
trace
(
'
Sending env to running instance...
'
);
await
service
.
start
(
environmentService
.
args
,
process
.
env
as
platform
.
IProcessEnvironment
);
// Cleanup
await
client
.
dispose
();
// Now that we started, make sure the warning dialog is prevented
if
(
startupWarningDialogHandle
)
{
clearTimeout
(
startupWarningDialogHandle
);
}
throw
new
ExpectedError
(
'
Sent env to running instance. Terminating...
'
);
client
=
await
connect
(
environmentService
.
mainIPCHandle
,
'
main
'
);
}
catch
(
error
)
{
// Handle unexpected connection errors by showing a dialog to the user
if
(
!
retry
||
platform
.
isWindows
||
error
.
code
!==
'
ECONNREFUSED
'
)
{
if
(
error
.
code
===
'
EPERM
'
)
{
showStartupWarningDialog
(
...
...
@@ -164,8 +108,8 @@ function setupIPC(accessor: ServicesAccessor): Promise<Server> {
}
// it happens on Linux and OS X that the pipe is left behind
// let's delete it, since we can't connect to it
//
and then
retry the whole thing
// let's delete it, since we can't connect to it
and then
// retry the whole thing
try
{
fs
.
unlinkSync
(
environmentService
.
mainIPCHandle
);
}
catch
(
error
)
{
...
...
@@ -175,6 +119,70 @@ function setupIPC(accessor: ServicesAccessor): Promise<Server> {
return
setup
(
false
);
}
// Tests from CLI require to be the only instance currently
if
(
environmentService
.
extensionTestsLocationURI
&&
!
environmentService
.
debugExtensionHost
.
break
)
{
const
msg
=
'
Running extension tests from the command line is currently only supported if no other instance of Code is running.
'
;
logService
.
error
(
msg
);
client
.
dispose
();
throw
new
Error
(
msg
);
}
// Show a warning dialog after some timeout if it takes long to talk to the other instance
// Skip this if we are running with --wait where it is expected that we wait for a while.
// Also skip when gathering diagnostics (--status) which can take a longer time.
let
startupWarningDialogHandle
:
NodeJS
.
Timeout
|
undefined
=
undefined
;
if
(
!
environmentService
.
wait
&&
!
environmentService
.
status
&&
!
environmentService
.
args
[
'
upload-logs
'
])
{
startupWarningDialogHandle
=
setTimeout
(()
=>
{
showStartupWarningDialog
(
localize
(
'
secondInstanceNoResponse
'
,
"
Another instance of {0} is running but not responding
"
,
product
.
nameShort
),
localize
(
'
secondInstanceNoResponseDetail
'
,
"
Please close all other instances and try again.
"
)
);
},
10000
);
}
const
channel
=
client
.
getChannel
(
'
launch
'
);
const
service
=
new
LaunchChannelClient
(
channel
);
// Process Info
if
(
environmentService
.
args
.
status
)
{
return
instantiationService
.
invokeFunction
(
async
accessor
=>
{
const
diagnostics
=
await
accessor
.
get
(
IDiagnosticsService
).
getDiagnostics
(
service
);
console
.
log
(
diagnostics
);
throw
new
ExpectedError
();
});
}
// Log uploader
if
(
typeof
environmentService
.
args
[
'
upload-logs
'
]
!==
'
undefined
'
)
{
return
instantiationService
.
invokeFunction
(
async
accessor
=>
{
await
uploadLogs
(
service
,
accessor
.
get
(
IRequestService
),
environmentService
);
throw
new
ExpectedError
();
});
}
// Windows: allow to set foreground
if
(
platform
.
isWindows
)
{
await
windowsAllowSetForegroundWindow
(
service
);
}
// Send environment over...
logService
.
trace
(
'
Sending env to running instance...
'
);
await
service
.
start
(
environmentService
.
args
,
process
.
env
as
platform
.
IProcessEnvironment
);
// Cleanup
await
client
.
dispose
();
// Now that we started, make sure the warning dialog is prevented
if
(
startupWarningDialogHandle
)
{
clearTimeout
(
startupWarningDialogHandle
);
}
throw
new
ExpectedError
(
'
Sent env to running instance. Terminating...
'
);
}
// Print --status usage info
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录