J'ai juste update le cutie.js, CONNARD
Ah oui, j'ai aussi add le info.js, qui est merdique d'ailleurs
This commit is contained in:
Syxpi
2025-10-11 22:06:46 +02:00
parent 14d4df5a40
commit b5cba1c318
283 changed files with 15040 additions and 12924 deletions

View File

@@ -392,7 +392,7 @@ class BaseConnection extends EventEmitter {
secureSocket.on('data', (data) => {
this.packetParser.execute(data);
});
this.write = (buffer) => secureSocket.write(buffer);
this.stream = secureSocket;
}
protocolError(message, code) {

View File

@@ -200,7 +200,11 @@ class BasePool extends EventEmitter {
Date.now() - this._freeConnections.get(0).lastActiveTime >
this.config.idleTimeout)
) {
this._freeConnections.get(0).destroy();
if (this.config.connectionConfig.gracefulEnd) {
this._freeConnections.get(0).end();
} else {
this._freeConnections.get(0).destroy();
}
}
} finally {
this._removeIdleTimeoutConnections();

View File

@@ -30,6 +30,13 @@ class BasePoolConnection extends BaseConnection {
}
end() {
if (this.config.gracefulEnd) {
this._removeFromPool();
super.end();
return;
}
const err = new Error(
'Calling conn.end() to release a pooled connection is ' +
'deprecated. In next version calling conn.end() will be ' +

View File

@@ -271,30 +271,67 @@ class Query extends Command {
}
stream(options) {
options = options || {};
options = options || Object.create(null);
options.objectMode = true;
const stream = new Readable(options);
stream._read = () => {
this._connection && this._connection.resume();
};
this.on('result', (row, resultSetIndex) => {
if (!stream.push(row)) {
this._connection.pause();
const stream = new Readable({
...options,
emitClose: true,
autoDestroy: true,
read: () => {
this._connection && this._connection.resume();
},
});
// Prevent a breaking change for users that rely on `end` event
stream.once('close', () => {
if (!stream.readableEnded) {
stream.emit('end');
}
stream.emit('result', row, resultSetIndex); // replicate old emitter
});
this.on('error', (err) => {
stream.emit('error', err); // Pass on any errors
});
this.on('end', () => {
stream.push(null); // pushing null, indicating EOF
});
this.on('fields', (fields) => {
const onResult = (row, index) => {
if (stream.destroyed) return;
if (!stream.push(row)) {
this._connection && this._connection.pause();
}
stream.emit('result', row, index); // replicate old emitter
};
const onFields = (fields) => {
if (stream.destroyed) return;
stream.emit('fields', fields); // replicate old emitter
});
stream.on('end', () => {
stream.emit('close');
});
};
const onEnd = () => {
if (stream.destroyed) return;
stream.push(null); // pushing null, indicating EOF
};
const onError = (err) => {
stream.destroy(err);
};
stream._destroy = (err, cb) => {
this._connection && this._connection.resume();
this.removeListener('result', onResult);
this.removeListener('fields', onFields);
this.removeListener('end', onEnd);
this.removeListener('error', onError);
cb(err); // Pass on any errors
};
this.on('result', onResult);
this.on('fields', onFields);
this.on('end', onEnd);
this.on('error', onError);
return stream;
}

View File

@@ -68,6 +68,7 @@ const validOptions = {
queueLimit: 1,
waitForConnections: 1,
jsonStrings: 1,
gracefulEnd: 1,
};
class ConnectionConfig {
@@ -190,6 +191,7 @@ class ConnectionConfig {
};
this.maxPreparedStatements = options.maxPreparedStatements || 16000;
this.jsonStrings = options.jsonStrings || false;
this.gracefulEnd = options.gracefulEnd || false;
}
static mergeFlags(default_flags, user_flags) {