Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ping service timeout #825

Merged
merged 3 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/customservices.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ This card checks if the target link is available. All you need is to set the `ty
logo: "assets/tools/sample.png"
url: "https://www.wikipedia.org/"
# method: "head"
# timeout: 500 # in ms. default 2000
# subtitle: "Bookmark example" # By default, request round trip time is displayed when subtitle is not set.
```

Expand Down
8 changes: 7 additions & 1 deletion src/components/services/Ping.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,14 @@ export default {
}

const startTime = performance.now();
const timeout = parseInt(this.item.timeout, 10) || 2000;
const params = {
method,
cache: "no-cache",
signal: AbortSignal.timeout(timeout)
};

this.fetch("/", { method, cache: "no-cache" }, false)
this.fetch("/", params, false)
.then(() => {
this.status = "online";
const endTime = performance.now();
Expand Down