feat: retry when initDesc Failed
This commit is contained in:
parent
6e233991b4
commit
516d7f5fbd
4 changed files with 22 additions and 2 deletions
1
.npmrc
1
.npmrc
|
@ -1 +1,2 @@
|
||||||
link-workspace-packages=true
|
link-workspace-packages=true
|
||||||
|
@jsr:registry=https://npm.jsr.io
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@std/async": "npm:@jsr/std__async@^1.0.12",
|
||||||
"@zip.js/zip.js": "^2.7.52",
|
"@zip.js/zip.js": "^2.7.52",
|
||||||
"better-sqlite3": "^9.6.0",
|
"better-sqlite3": "^9.6.0",
|
||||||
"chokidar": "^3.6.0",
|
"chokidar": "^3.6.0",
|
||||||
|
|
|
@ -3,6 +3,7 @@ import type { DocumentBody } from "dbtype";
|
||||||
import { readZip } from "../util/zipwrap.ts";
|
import { readZip } from "../util/zipwrap.ts";
|
||||||
import { type ContentConstructOption, createDefaultClass, registerContentReferrer } from "./file.ts";
|
import { type ContentConstructOption, createDefaultClass, registerContentReferrer } from "./file.ts";
|
||||||
import { TextWriter } from "@zip.js/zip.js";
|
import { TextWriter } from "@zip.js/zip.js";
|
||||||
|
import { retry } from "@std/async"
|
||||||
|
|
||||||
type ComicType = "doujinshi" | "artist cg" | "manga" | "western";
|
type ComicType = "doujinshi" | "artist cg" | "manga" | "western";
|
||||||
interface ComicDesc {
|
interface ComicDesc {
|
||||||
|
@ -43,8 +44,16 @@ export class ComicReferrer extends createDefaultClass("comic") {
|
||||||
.then(() => zip.handle.close());
|
.then(() => zip.handle.close());
|
||||||
}
|
}
|
||||||
|
|
||||||
async createDocumentBody(): Promise<DocumentBody> {
|
override async createDocumentBody(): Promise<DocumentBody> {
|
||||||
await this.initDesc();
|
await retry(async () => {
|
||||||
|
await this.initDesc();
|
||||||
|
}, {
|
||||||
|
jitter: 0.5,
|
||||||
|
maxAttempts: 5,
|
||||||
|
minTimeout: 10,
|
||||||
|
maxTimeout: 1000,
|
||||||
|
multiplier: 2,
|
||||||
|
});
|
||||||
const basebody = await super.createDocumentBody();
|
const basebody = await super.createDocumentBody();
|
||||||
this.desc?.title;
|
this.desc?.title;
|
||||||
if (this.desc === undefined) {
|
if (this.desc === undefined) {
|
||||||
|
|
9
pnpm-lock.yaml
generated
9
pnpm-lock.yaml
generated
|
@ -169,6 +169,9 @@ importers:
|
||||||
|
|
||||||
packages/server:
|
packages/server:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
'@std/async':
|
||||||
|
specifier: npm:@jsr/std__async@^1.0.12
|
||||||
|
version: '@jsr/std__async@1.0.12'
|
||||||
'@zip.js/zip.js':
|
'@zip.js/zip.js':
|
||||||
specifier: ^2.7.52
|
specifier: ^2.7.52
|
||||||
version: 2.7.52
|
version: 2.7.52
|
||||||
|
@ -782,6 +785,9 @@ packages:
|
||||||
'@jridgewell/trace-mapping@0.3.25':
|
'@jridgewell/trace-mapping@0.3.25':
|
||||||
resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==}
|
resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==}
|
||||||
|
|
||||||
|
'@jsr/std__async@1.0.12':
|
||||||
|
resolution: {integrity: sha512-NUaSOcwMetVeVkIqet2Ammy2A5YxG8ViFxryBbTaC4h7l/cgAkU59U3zF58ek4Y8HZ0Nx5De7qBptPfp62kcgw==, tarball: https://npm.jsr.io/~/11/@jsr/std__async/1.0.12.tgz}
|
||||||
|
|
||||||
'@nodelib/fs.scandir@2.1.5':
|
'@nodelib/fs.scandir@2.1.5':
|
||||||
resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==}
|
resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==}
|
||||||
engines: {node: '>= 8'}
|
engines: {node: '>= 8'}
|
||||||
|
@ -2706,6 +2712,7 @@ packages:
|
||||||
node-domexception@1.0.0:
|
node-domexception@1.0.0:
|
||||||
resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==}
|
resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==}
|
||||||
engines: {node: '>=10.5.0'}
|
engines: {node: '>=10.5.0'}
|
||||||
|
deprecated: Use your platform's native DOMException instead
|
||||||
|
|
||||||
node-fetch@3.3.2:
|
node-fetch@3.3.2:
|
||||||
resolution: {integrity: sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==}
|
resolution: {integrity: sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==}
|
||||||
|
@ -3970,6 +3977,8 @@ snapshots:
|
||||||
'@jridgewell/resolve-uri': 3.1.2
|
'@jridgewell/resolve-uri': 3.1.2
|
||||||
'@jridgewell/sourcemap-codec': 1.5.0
|
'@jridgewell/sourcemap-codec': 1.5.0
|
||||||
|
|
||||||
|
'@jsr/std__async@1.0.12': {}
|
||||||
|
|
||||||
'@nodelib/fs.scandir@2.1.5':
|
'@nodelib/fs.scandir@2.1.5':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@nodelib/fs.stat': 2.0.5
|
'@nodelib/fs.stat': 2.0.5
|
||||||
|
|
Loading…
Add table
Reference in a new issue