From 346d9c8e90173328a28e05cdfac911fb5103dd19 Mon Sep 17 00:00:00 2001 From: Yuki Tanaka Date: Wed, 25 Sep 2024 21:59:17 +0900 Subject: [PATCH] deps: `deno@2.0.0-rc.5` (#448) --- .denov | 2 +- .octocov.yml | 6 +++--- deno.json | 9 +++++---- errors.ts | 2 +- experimental/cluster/mod.ts | 7 ++++++- tests/test_util.ts | 2 +- tools/make_mod.ts | 14 +++++++++----- 7 files changed, 26 insertions(+), 16 deletions(-) diff --git a/.denov b/.denov index 3fb13d4f..e0934080 100644 --- a/.denov +++ b/.denov @@ -1 +1 @@ -2.0.0-rc.0 +2.0.0-rc.5 diff --git a/.octocov.yml b/.octocov.yml index a70df7e9..61edfc07 100644 --- a/.octocov.yml +++ b/.octocov.yml @@ -1,10 +1,10 @@ # generated by octocov init codeToTestRatio: code: - - '**/*.ts' - - '!tests/*.ts' + - "**/*.ts" + - "!tests/*.ts" test: - - 'tests/*.ts' + - "tests/*.ts" coverage: paths: - coverage/lcov.info diff --git a/deno.json b/deno.json index 4f6a4a6e..428ae2c8 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,7 @@ { "exclude": [ - "benchmark/node_modules" + "benchmark/node_modules", + "tmp" ], "lint": { "exclude": [ @@ -10,15 +11,15 @@ "rules": { "include": ["no-console"] } }, "test": { - "exclude": ["benchmark/", "tmp/", "vendor/"] + "exclude": ["benchmark/", "vendor/"] }, "tasks": { "lock": "rm deno.lock && DENO_FUTURE=1 deno cache --reload mod.ts experimental/**/mod.ts tests/**/*.ts", "check:deno-json": "deno run --allow-read=deno.json tools/check_deno_json.js", "test": "DENO_FUTURE=1 deno test --allow-net --allow-read=tests --allow-write=tests/tmp --allow-run=redis-server,redis-cli --coverage=coverage --trace-leaks --frozen-lockfile", - "test:doc": "deno test --doc --no-run --import-map=import_map.test.json", + "test:doc": "deno check --doc-only --import-map=import_map.test.json README.md experimental/cluster/README.md", "coverage": "deno coverage ./coverage --lcov --output=coverage/lcov.info", - "make_mod": "deno run --allow-read --allow-write --allow-run --check tools/make_mod.ts", + "make_mod": "deno run --allow-read --allow-write --allow-run=deno --check tools/make_mod.ts", "bench:deno-redis": "DENO_NO_PACKAGE_JSON=1 deno run --unstable --allow-net=127.0.0.1:6379 --allow-read --allow-env --allow-write=tmp --import-map=benchmark/import_map.json benchmark/deno-redis.ts", "bench:ioredis": "node benchmark/ioredis.js" } diff --git a/errors.ts b/errors.ts index fddb4d23..a96f4477 100644 --- a/errors.ts +++ b/errors.ts @@ -18,7 +18,7 @@ export class InvalidStateError extends Error { } } -export function isRetriableError(error: Error): boolean { +export function isRetriableError(error: unknown): boolean { return (error instanceof Deno.errors.BadResource || error instanceof Deno.errors.BrokenPipe || error instanceof Deno.errors.ConnectionAborted || diff --git a/experimental/cluster/mod.ts b/experimental/cluster/mod.ts index c173ca71..7f23e7e6 100644 --- a/experimental/cluster/mod.ts +++ b/experimental/cluster/mod.ts @@ -136,7 +136,12 @@ class ClusterExecutor implements CommandExecutor { const reply = await r.sendCommand(command, args, options); return reply; } catch (err) { - lastError = err; + if (err instanceof Error) { + lastError = err; + } else { + throw err; // An unexpected error occurred. + } + if (err instanceof Deno.errors.BadResource) { tryRandomNode = true; if (ttl < kRedisClusterRequestTTL / 2) { diff --git a/tests/test_util.ts b/tests/test_util.ts index 87d88244..ae084cbe 100644 --- a/tests/test_util.ts +++ b/tests/test_util.ts @@ -66,7 +66,7 @@ export async function ensureTerminated( await process.status; } catch (error) { const alreadyKilled = error instanceof TypeError && - error.message === "Child process has already terminated."; + error.message === "Child process has already terminated"; if (alreadyKilled) { return; } diff --git a/tools/make_mod.ts b/tools/make_mod.ts index c8039136..a1ea52d5 100755 --- a/tools/make_mod.ts +++ b/tools/make_mod.ts @@ -11,7 +11,11 @@ interface Node { declarationKind: "export" | "private"; } -async function doc(fileName: string): Promise> { +interface Doc { + nodes: Array; +} + +async function doc(fileName: string): Promise { const deno = new Deno.Command(Deno.execPath(), { args: ["doc", "--json", fileName], }); @@ -52,7 +56,7 @@ let content = `// Generated by tools/make_mod.ts. Don't edit.\n`; // Expose public variables from protocol/shared/types.ts { const fileName = "protocol/shared/types.ts"; - const variables = (await doc(fileName)).filter((node) => { + const variables = (await doc(fileName)).nodes.filter((node) => { return node.kind === "variable"; }).map((node) => node.name); content += `export { ${variables.join(",")} } from "./${fileName}";\n`; @@ -61,7 +65,7 @@ let content = `// Generated by tools/make_mod.ts. Don't edit.\n`; // Expose public functions from redis.ts. { const fileName = "redis.ts"; - const functions = (await doc(fileName)).filter((node) => { + const functions = (await doc(fileName)).nodes.filter((node) => { return node.kind === "function"; }).map((node) => node.name); content += `export { ${functions.join(",")} } from "./${fileName}";\n`; @@ -70,7 +74,7 @@ let content = `// Generated by tools/make_mod.ts. Don't edit.\n`; // Expose public classes from errors.ts { const fileName = "errors.ts"; - const classes = (await doc(fileName)).filter((node) => { + const classes = (await doc(fileName)).nodes.filter((node) => { return node.kind === "class"; }).map((node) => node.name); content += `export { ${classes.join(",")} } from "./${fileName}";\n`; @@ -78,7 +82,7 @@ let content = `// Generated by tools/make_mod.ts. Don't edit.\n`; // Expose types from *.ts. for (const f of files) { - const types = (await doc(f)).filter((node) => { + const types = (await doc(f)).nodes.filter((node) => { return (node.kind === "interface" || node.kind === "typeAlias") && node.declarationKind !== "private"; }).map((node) => node.name);