RedisClientType
type is slow to typecheck (TS performance issue)
#2975
Labels
RedisClientType
type is slow to typecheck (TS performance issue)
#2975
Description
We just upgraded
redis
from4.7.0
to5.1.0
. In our CI we have a job to verify that all types are still correct (usingtsc --noEmit
). Since upgradingredis
this job now runs out of memory:CI log
I can reproduce this locally using
NODE_OPTIONS="--max-old-space-size=2048" pnpm tsc --noEmit -p tsconfig.test.json
(this does also include our application code, so the max size is probably different for a small reproduction).I analyzed the output on my local machine (Macbook M3 Pro, 36GB RAM) using
@typescript/analyze-trace
, which gave the following output:This led me to a file used in our tests:
Affected code (unrelated code omitted for brevity)
It seems that type checking
RedisClientType
is taking 2.7s locally, most likely taking up a bunch of memory as it does so. From the output it seems the culprit is somewhere inmulti-command.d.ts
.Replacing
RedisClientType
with{ connect: () => Promise<unknown>; quit: () => Promise<unknown> }
fixes the issue for us, since those are the only two methods we use anyway.This fixes the issue for us, as running
NODE_OPTIONS="--max-old-space-size=2048" pnpm tsc --noEmit -p tsconfig.test.json
now finishes without errors. Our CI also no longer runs out of memory.Node.js Version
22.14.0
Redis Server Version
Node Redis Version
5.1.0
Platform
MacOS, Linux
Logs
The text was updated successfully, but these errors were encountered: