Skip to content
Open
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
22 changes: 19 additions & 3 deletions runtime/caches/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@ import {
NOT_IMPLEMENTED,
withCacheNamespace,
} from "./utils.ts";
import { ValueType } from "../../deps.ts";
import { meter } from "../../observability/otel/metrics.ts";
import { Redis } from "npm:ioredis@^5.10.1";

const cacheError = meter.createCounter("cache_error", {
description: "Number of Redis cache operation errors",
unit: "1",
valueType: ValueType.INT,
});

const CONNECTION_TIMEOUT = parseInt(
Deno.env.get("LOADER_CACHE_REDIS_CONNECTION_TIMEOUT_MS") || "2000",
);
Expand Down Expand Up @@ -107,7 +115,10 @@ export function create(redis: RedisConnection | null, namespace: string) {
COMMAND_TIMEOUT,
)
)
.catch(() => 0);
.catch(() => {
cacheError.add(1, { engine: "REDIS", operation: "delete" });
return 0;
});

return result > 0;
},
Expand All @@ -131,7 +142,10 @@ export function create(redis: RedisConnection | null, namespace: string) {

return deserialize(result);
})
.catch(() => undefined);
.catch(() => {
cacheError.add(1, { engine: "REDIS", operation: "match" });
return undefined;
});

return result;
},
Expand All @@ -155,7 +169,9 @@ export function create(redis: RedisConnection | null, namespace: string) {
COMMAND_TIMEOUT,
)
)
.catch(() => {});
.catch(() => {
cacheError.add(1, { engine: "REDIS", operation: "put" });
});
Comment on lines +172 to +174

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

CI is failing due to line-ending normalization in this hunk.

Deno fmt --check is currently failing (CRLF vs LF near Line 168-Line 169). Please normalize this file to LF (e.g., run formatter once on the file) so the pipeline passes.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@runtime/caches/redis.ts` around lines 172 - 174, Normalize the line endings
in the runtime/caches/redis.ts file to LF so Deno's formatter check passes; open
the file and convert CRLF to LF (e.g., run `deno fmt` or your editor's "LF"
conversion) and re-save so the catch block around the cacheError.add(1, {
engine: "REDIS", operation: "put" }); lines use LF endings; commit the
normalized file (or add a .gitattributes entry to enforce LF) and re-run CI.

},
};
}
Expand Down
Loading