feat: retry when initDesc Failed

This commit is contained in:
monoid 2025-05-01 16:12:14 +09:00
parent 6e233991b4
commit 516d7f5fbd
4 changed files with 22 additions and 2 deletions

1
.npmrc
View file

@ -1 +1,2 @@
link-workspace-packages=true
@jsr:registry=https://npm.jsr.io

View file

@ -11,6 +11,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@std/async": "npm:@jsr/std__async@^1.0.12",
"@zip.js/zip.js": "^2.7.52",
"better-sqlite3": "^9.6.0",
"chokidar": "^3.6.0",

View file

@ -3,6 +3,7 @@ import type { DocumentBody } from "dbtype";
import { readZip } from "../util/zipwrap.ts";
import { type ContentConstructOption, createDefaultClass, registerContentReferrer } from "./file.ts";
import { TextWriter } from "@zip.js/zip.js";
import { retry } from "@std/async"
type ComicType = "doujinshi" | "artist cg" | "manga" | "western";
interface ComicDesc {
@ -43,8 +44,16 @@ export class ComicReferrer extends createDefaultClass("comic") {
.then(() => zip.handle.close());
}
async createDocumentBody(): Promise<DocumentBody> {
await this.initDesc();
override async createDocumentBody(): Promise<DocumentBody> {
await retry(async () => {
await this.initDesc();
}, {
jitter: 0.5,
maxAttempts: 5,
minTimeout: 10,
maxTimeout: 1000,
multiplier: 2,
});
const basebody = await super.createDocumentBody();
this.desc?.title;
if (this.desc === undefined) {

9
pnpm-lock.yaml generated
View file

@ -169,6 +169,9 @@ importers:
packages/server:
dependencies:
'@std/async':
specifier: npm:@jsr/std__async@^1.0.12
version: '@jsr/std__async@1.0.12'
'@zip.js/zip.js':
specifier: ^2.7.52
version: 2.7.52
@ -782,6 +785,9 @@ packages:
'@jridgewell/trace-mapping@0.3.25':
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':
resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==}
engines: {node: '>= 8'}
@ -2706,6 +2712,7 @@ packages:
node-domexception@1.0.0:
resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==}
engines: {node: '>=10.5.0'}
deprecated: Use your platform's native DOMException instead
node-fetch@3.3.2:
resolution: {integrity: sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==}
@ -3970,6 +3977,8 @@ snapshots:
'@jridgewell/resolve-uri': 3.1.2
'@jridgewell/sourcemap-codec': 1.5.0
'@jsr/std__async@1.0.12': {}
'@nodelib/fs.scandir@2.1.5':
dependencies:
'@nodelib/fs.stat': 2.0.5