Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
A
aspnetcore
管理
动态
成员
标记
计划
议题
议题看板
里程碑
Wiki
代码
合并请求
仓库
分支
提交
标签
仓库图
比较修订版本
代码片段
构建
流水线
作业
流水线计划
产物
部署
发布
Package registry
Container registry
模型注册表
运维
环境
Terraform 模块
监控
事件
服务台
分析
价值流分析
贡献者分析
CI/CD 分析
仓库分析
模型实验
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
dotnet
aspnetcore
提交
1282fde3
提交
1282fde3
编辑于
6 years ago
作者:
Andrew Stanton-Nurse
浏览文件
操作
下载
补丁
差异文件
less flaky test
上级
6f77eaca
No related branches found
No related tags found
无相关合并请求
变更
2
隐藏空白变更内容
行内
左右并排
显示
2 个更改的文件
clients/ts/signalr/spec/LongPollingTransport.spec.ts
+3
-4
3 个添加, 4 个删除
clients/ts/signalr/spec/LongPollingTransport.spec.ts
clients/ts/signalr/src/LongPollingTransport.ts
+12
-3
12 个添加, 3 个删除
clients/ts/signalr/src/LongPollingTransport.ts
有
15 个添加
和
7 个删除
clients/ts/signalr/spec/LongPollingTransport.spec.ts
+
3
−
4
浏览文件 @
1282fde3
...
...
@@ -8,6 +8,7 @@ import { ConsoleLogger } from "../src/Utils";
import
{
TestHttpClient
}
from
"
./TestHttpClient
"
;
import
{
asyncit
as
it
,
PromiseSource
,
delay
}
from
"
./Utils
"
;
import
{
HttpError
,
TimeoutError
}
from
"
../src/Errors
"
;
import
{
AbortSignal
}
from
"
../src/AbortController
"
;
describe
(
"
LongPollingTransport
"
,
()
=>
{
it
(
"
shuts down poll after timeout even if server doesn't shut it down on receiving the DELETE
"
,
async
()
=>
{
...
...
@@ -59,7 +60,6 @@ describe("LongPollingTransport", () => {
deleteReceived
.
resolve
();
return
new
HttpResponse
(
202
);
});
const
logMessages
:
string
[]
=
[];
const
transport
=
new
LongPollingTransport
(
client
,
null
,
NullLogger
.
instance
,
false
,
100
);
await
transport
.
connect
(
"
http://example.com
"
,
TransferFormat
.
Text
);
...
...
@@ -115,9 +115,8 @@ describe("LongPollingTransport", () => {
// fake timers!
await
delay
(
150
);
expect
(
logMessages
)
.
not
.
toContain
(
"
(LongPolling transport) server did not terminate after DELETE request, canceling poll.
"
);
// The pollAbort token should be left unaborted because we shut down gracefully.
expect
(
transport
.
pollAborted
).
toBe
(
false
);
});
}
});
\ No newline at end of file
此差异已折叠。
点击以展开。
clients/ts/signalr/src/LongPollingTransport.ts
+
12
−
3
浏览文件 @
1282fde3
...
...
@@ -10,6 +10,7 @@ import { Arg, getDataDetail, sendMessage } from "./Utils";
const
SHUTDOWN_TIMEOUT
=
5
*
1000
;
// Not exported from 'index', this type is internal.
export
class
LongPollingTransport
implements
ITransport
{
private
readonly
httpClient
:
HttpClient
;
private
readonly
accessTokenFactory
:
()
=>
string
|
Promise
<
string
>
;
...
...
@@ -22,6 +23,12 @@ export class LongPollingTransport implements ITransport {
private
shutdownTimer
:
any
;
// We use 'any' because this is an object in NodeJS. But it still gets passed to clearTimeout, so it doesn't really matter
private
shutdownTimeout
:
number
;
private
running
:
boolean
;
private
stopped
:
boolean
;
// This is an internal type, not exported from 'index' so this is really just internal.
public
get
pollAborted
()
{
return
this
.
pollAbort
.
aborted
;
}
constructor
(
httpClient
:
HttpClient
,
accessTokenFactory
:
()
=>
string
|
Promise
<
string
>
,
logger
:
ILogger
,
logMessageContent
:
boolean
,
shutdownTimeout
?:
number
)
{
this
.
httpClient
=
httpClient
;
...
...
@@ -144,8 +151,8 @@ export class LongPollingTransport implements ITransport {
}
}
}
finally
{
//
Trigger the poll aborted token so we don't set the shutdown timer
this
.
pollAbort
.
abort
()
;
//
Indicate that we've stopped so the shutdown timer doesn't get registered.
this
.
stopped
=
true
;
// Clean up the shutdown timer if it was registered
if
(
this
.
shutdownTimer
)
{
...
...
@@ -185,9 +192,11 @@ export class LongPollingTransport implements ITransport {
this
.
logger
.
log
(
LogLevel
.
Trace
,
"
(LongPolling transport) DELETE request accepted.
"
);
}
finally
{
// Abort the poll after the shutdown timeout if the server doesn't stop the poll.
if
(
!
this
.
pollAbort
.
abort
ed
)
{
if
(
!
this
.
stopp
ed
)
{
this
.
shutdownTimer
=
setTimeout
(()
=>
{
this
.
logger
.
log
(
LogLevel
.
Warning
,
"
(LongPolling transport) server did not terminate after DELETE request, canceling poll.
"
);
// Abort any outstanding poll
this
.
pollAbort
.
abort
();
},
this
.
shutdownTimeout
);
}
...
...
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录