Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions src/security/sandbox/project-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ import type {
const logger = serverLogger.component("project-worker");
const textEncoder = new TextEncoder();

type ExtendedWorkerOptions = {
type: "module";
name?: string;
// Intersection with the DOM `WorkerOptions` so the value is assignable to the
// `Worker` constructor without suppression — Deno reads the extra `deno` field
// at runtime even though the DOM lib type doesn't declare it.
type ExtendedWorkerOptions = WorkerOptions & {
deno?: { permissions: WorkerPermissions };
};

Expand Down Expand Up @@ -103,7 +104,6 @@ export class ProjectWorker {
deno: { permissions: this.permissions },
};

// @ts-ignore - Deno Worker accepts extended options
this.worker = new Worker(workerUrl, workerOptions);
this._status = "idle";

Expand Down
21 changes: 15 additions & 6 deletions src/utils/redis-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ export interface RedisClientOptions {
username?: string;
}

/**
* Minimal subset of `@redis/client`'s `createClient` options that we actually
* pass. Declared locally so we don't depend on the untyped npm surface (the
* module is loaded via a dynamic `import()` and is otherwise `any`).
*/
interface RedisClientFactoryOptions {
url?: string;
socket?: { tls?: boolean };
password?: string;
username?: string;
}

let sharedClient: RedisClient | null = null;
let connectionPromise: Promise<RedisClient> | null = null;
let isConnecting = false;
Expand Down Expand Up @@ -67,14 +79,12 @@ export async function getRedisClient(options: RedisClientOptions = {}): Promise<
}

async function createClient(options: RedisClientOptions): Promise<RedisClient> {
// deno-lint-ignore no-explicit-any
let createClientFn: ((opts: Record<string, any>) => RedisClient) | undefined;
let createClientFn: ((opts: RedisClientFactoryOptions) => RedisClient) | undefined;

try {
const redisClientModule = "npm:@redis/client@1.5.8";
const mod = await import(redisClientModule);
// deno-lint-ignore no-explicit-any
createClientFn = mod.createClient as (opts: Record<string, any>) => RedisClient;
createClientFn = mod.createClient as (opts: RedisClientFactoryOptions) => RedisClient;
} catch (error) {
logger.debug("Failed to load @redis/client module", { error });
throw DEPENDENCY_MISSING.create({
Expand All @@ -92,8 +102,7 @@ async function createClient(options: RedisClientOptions): Promise<RedisClient> {
);
}

// deno-lint-ignore no-explicit-any
const clientOpts: Record<string, any> = { url };
const clientOpts: RedisClientFactoryOptions = { url };
if (useTls) {
clientOpts.socket = { tls: true };
}
Expand Down