Bug Description
Connector.startLocalProxy() adds every socket pair it creates to this.sockets and never removes them when they close. In a long-running process this retains one TLSSocket (and its native OpenSSL SecureContext) per pooled database connection for the lifetime of the process.
Root cause
src/connector.ts, in startLocalProxy:
server.on('connection', c => {
const s = stream();
this.sockets.add(s); // TLS socket to Cloud SQL
this.sockets.add(c); // local unix domain socket
c.pipe(s);
s.pipe(c);
});
Both sockets are added to the Set and nothing ever removes them. The Set is only read by close(), so entries for long-closed connections stay reachable forever keeping each TLSSocket alive along with its native SecureContext.
The library already solves this correctly elsewhere. Example CloudSQLInstance.addSocket in src/cloud-sql-instance.ts:
this.sockets.add(socket);
// When the socket is closed, remove it.
socket.once('closed', () => {
this.sockets.delete(socket);
});
That cleanup was never applied to the startLocalProxy path.
Also I think the readme example of usage with Prisma should be updated. Prisma now supports driver adapters.
Bug Description
Connector.startLocalProxy()adds every socket pair it creates tothis.socketsand never removes them when they close. In a long-running process this retains oneTLSSocket(and its native OpenSSLSecureContext) per pooled database connection for the lifetime of the process.Root cause
src/connector.ts, instartLocalProxy:Both sockets are added to the
Setand nothing ever removes them. TheSetis only read byclose(), so entries for long-closed connections stay reachable forever keeping eachTLSSocketalive along with its nativeSecureContext.The library already solves this correctly elsewhere. Example
CloudSQLInstance.addSocketinsrc/cloud-sql-instance.ts:That cleanup was never applied to the
startLocalProxypath.Also I think the readme example of usage with Prisma should be updated. Prisma now supports driver adapters.