diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 02390cf..55e7585 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,6 +48,9 @@ jobs: - name: Workers build run: npm run cf:build + - name: Legacy Pages build + run: npm run pages:build + - name: Audit production dependencies (high severity+) run: npm audit --omit=dev --audit-level=high diff --git a/lib/server/redis-client.ts b/lib/server/redis-client.ts index af378c9..94e15db 100644 --- a/lib/server/redis-client.ts +++ b/lib/server/redis-client.ts @@ -1,6 +1,7 @@ import 'server-only'; import { Redis } from '@upstash/redis'; +import type { Socket } from 'node:net'; type RedisPrimitive = string | number | null; type RedisRawValue = RedisPrimitive | RedisRawValue[]; @@ -128,6 +129,16 @@ function encodeCommand(args: string[]): Buffer { return Buffer.from(parts.join('')); } +async function importNodeNet(): Promise { + const moduleName = 'node:' + 'net'; + return import(/* webpackIgnore: true */ moduleName) as Promise; +} + +async function importNodeTls(): Promise { + const moduleName = 'node:' + 'tls'; + return import(/* webpackIgnore: true */ moduleName) as Promise; +} + function readLine(buffer: Buffer, offset: number): { line: string; offset: number } | null { const end = buffer.indexOf('\r\n', offset); if (end === -1) return null; @@ -207,17 +218,17 @@ async function sendRedisCommands(redisUrl: URL, commands: string[][]): Promise { socket = connect({ host, port, servername: host }, onReady); bindSocketHandlers(socket); }) .catch((error: unknown) => finish(() => reject(error))); } else { - import('node:net') + importNodeNet() .then(({ connect }) => { socket = connect({ host, port }, onReady); bindSocketHandlers(socket); @@ -225,7 +236,7 @@ async function sendRedisCommands(redisUrl: URL, commands: string[][]): Promise finish(() => reject(error))); } - function bindSocketHandlers(activeSocket: import('node:net').Socket): void { + function bindSocketHandlers(activeSocket: Socket): void { activeSocket.setTimeout(timeout); activeSocket.on('data', (chunk: Buffer) => {