Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
cdn-node-checker
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
cdn-node-checker
Commits
2ada27de
Commit
2ada27de
authored
Mar 24, 2023
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add timeout
parent
b70ecdb5
Pipeline
#20896
failed with stages
in 1 minute and 36 seconds
Changes
3
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
170 additions
and
58 deletions
+170
-58
package-lock.json
package-lock.json
+155
-52
package.json
package.json
+2
-1
run.ts
run.ts
+13
-5
No files found.
package-lock.json
View file @
2ada27de
This diff is collapsed.
Click to expand it.
package.json
View file @
2ada27de
...
...
@@ -18,11 +18,12 @@
"
@types/cron
"
:
"
^1.7.2
"
,
"
@types/q
"
:
"
^1.5.4
"
,
"
@types/yaml
"
:
"
^1.9.7
"
,
"
axios
"
:
"
^
0.19.2
"
,
"
axios
"
:
"
^
1.3.4
"
,
"
delay
"
:
"
^5.0.0
"
,
"
icmp
"
:
"
^2.0.1
"
,
"
lodash
"
:
"
^4.17.21
"
,
"
p-queue
"
:
"
6.6.2
"
,
"
p-timeout
"
:
"
4.1.0
"
,
"
q
"
:
"
^1.5.1
"
,
"
yaml
"
:
"
^1.10.0
"
},
...
...
run.ts
View file @
2ada27de
...
...
@@ -9,6 +9,7 @@ import { ping } from 'icmp';
import
delay
from
'
delay
'
;
import
PQueue
from
'
p-queue
'
;
import
https
from
'
https
'
;
import
pTimeout
from
'
p-timeout
'
;
interface
Source
{
protocol
:
string
;
...
...
@@ -280,7 +281,7 @@ class Checker {
const
socket
=
new
net
.
Socket
();
socket
.
connect
(
port
,
address
);
socket
.
setTimeout
(
this
.
config
.
timeout
||
1000
);
socket
.
setTimeout
(
this
.
config
.
timeout
);
socket
.
on
(
'
connect
'
,
()
=>
{
socket
.
destroy
();
...
...
@@ -463,11 +464,18 @@ class Checker {
);
let
lastResult
:
ConnectResult
;
for
(
let
i
=
1
;
i
<=
this
.
config
.
retryCount
;
++
i
)
{
const
result
=
await
checkMethodFunction
(
source
,
address
);
if
(
result
==
ConnectResult
.
Good
)
{
return
result
;
const
prom
=
checkMethodFunction
(
source
,
address
);
try
{
lastResult
=
await
pTimeout
(
prom
,
this
.
config
.
timeout
*
2
+
1000
);
}
catch
(
e
)
{
this
.
message
(
`Connection
${
this
.
getSourcePattern
(
source
,
address
)}
timeout.`
,
);
lastResult
=
ConnectResult
.
CDNBad
;
}
if
(
lastResult
==
ConnectResult
.
Good
)
{
return
lastResult
;
}
lastResult
=
result
;
}
if
(
lastResult
===
ConnectResult
.
CDNBad
)
{
this
.
message
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment