You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Private field holding new EventEmitter() from require("events") is unreadable when its class is constructed as a parent (next redis createClient blocker) #11131
A class constructor assigns new EventEmitter(), obtained through require("events"), to a #private field. When that class is constructed as the parent of a subclass, the field can't be read afterwards:
TypeError: Cannot access private member from an object whose class did not declare it
With import { EventEmitter } from "node:events" it works.
This is the next blocker for redis@6.1.0 createClient({ socket }), once #11120 (PR #11129) and #11042 (PR #11122) are applied. In @redis/client, RedisClient sets this.#socket to a RedisSocket extends EventEmitter (CommonJS require("node:events")) and is constructed through attachConfig's class extends BaseClass {}. client.connect() then fails at this._self.#socket.connect().
Perry origin/main784ed8e (perry-dev build): private threw Cannot access private member from an object whose class did not declare it
Observations
It only fails when the class is constructed as a parent. new Client().kind() works. It fails for new Sub() and for a dynamic new (Sub as any)().
The import { EventEmitter } from "node:events" form prints private object.
With const { EventEmitter } = require("events"), new EventEmitter() created in that constructor has .constructor !== EventEmitter (constructor.name is undefined), even when Client is constructed directly. .on is still a function.
A user class in place of EventEmitter works.
redis end-to-end status (for the record)
Fixture: redis 6.1.0 exact, compilePackages = redis, @redis/{client,bloom,json,search,time-series}, cluster-key-slot. Tested against a live redis-server. Node prints the full set/get/hSet/incr sequence. Perry on #11129 + #11122 gets through createClient({ socket }) and client.on("error", ...), then throws the error above from client.connect(). The same connect() failure reproduces in a small compiled-package fixture mirroring RedisSocket/RedisClient/attachConfig, and it is gone when RedisSocket does not extend EventEmitter.
Activity
test: private brand of an ancestor evaluation on subclass instances (#…
fix(runtime): resolve an ancestor's private brand through the instanc…
test: private brand of an ancestor evaluation on subclass instances (#…
test(gap): cover redis attachConfig's per-call class extends BaseClass (
fix(runtime): resolve an ancestor's private brand through the instanc…
test: private brand of an ancestor evaluation on subclass instances (#…
test(gap): cover redis attachConfig's per-call class extends BaseClass (
fix(runtime): resolve an ancestor's private brand through the instanc…
test: private brand of an ancestor evaluation on subclass instances (#…
test(gap): cover redis attachConfig's per-call class extends BaseClass (