parent
b1dcbc3454
commit
121ecb328a
|
@ -2,6 +2,8 @@ import { SpacePrimitives } from "./space_primitives.ts";
|
||||||
import { FileMeta } from "../../plug-api/types.ts";
|
import { FileMeta } from "../../plug-api/types.ts";
|
||||||
import { flushCachesAndUnregisterServiceWorker } from "../sw_util.ts";
|
import { flushCachesAndUnregisterServiceWorker } from "../sw_util.ts";
|
||||||
|
|
||||||
|
const fetchTimeout = 5000;
|
||||||
|
|
||||||
export class HttpSpacePrimitives implements SpacePrimitives {
|
export class HttpSpacePrimitives implements SpacePrimitives {
|
||||||
constructor(
|
constructor(
|
||||||
readonly url: string,
|
readonly url: string,
|
||||||
|
@ -29,6 +31,7 @@ export class HttpSpacePrimitives implements SpacePrimitives {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
options.signal = AbortSignal.timeout(fetchTimeout);
|
||||||
const result = await fetch(url, options);
|
const result = await fetch(url, options);
|
||||||
if (result.status === 503) {
|
if (result.status === 503) {
|
||||||
throw new Error("Offline");
|
throw new Error("Offline");
|
||||||
|
|
Loading…
Reference in New Issue