diff --git a/keyserver/flow-typed/npm/mysql_v2.x.x.js b/keyserver/flow-typed/npm/mysql_v2.x.x.js --- a/keyserver/flow-typed/npm/mysql_v2.x.x.js +++ b/keyserver/flow-typed/npm/mysql_v2.x.x.js @@ -42,7 +42,6 @@ multipleStatements?: boolean, flags?: string, ssl?: string | {...}, - ... }; declare type QueryOptions = { @@ -134,12 +133,12 @@ escape(val: mixed, stringifyObjects?: boolean, timeZone?: string): string; } - declare type PoolOptions = ConnectionOptions & { + declare type PoolOptions = { + ...ConnectionOptions, acquireTimeout?: number, connectionLimit?: number, waitForConnections?: boolean, queueLimit?: number, - ... }; declare type PoolClusterSelector = "RR" | "ORDER" | "RANDOM"; diff --git a/keyserver/src/database/database.js b/keyserver/src/database/database.js --- a/keyserver/src/database/database.js +++ b/keyserver/src/database/database.js @@ -1,6 +1,6 @@ // @flow -import type { QueryResults } from 'mysql'; +import type { ConnectionOptions, QueryResults, PoolOptions } from 'mysql'; import mysql from 'mysql2'; import mysqlPromise from 'mysql2/promise'; import SQL from 'sql-template-strings'; @@ -20,13 +20,14 @@ } const scriptContext = getScriptContext(); const dbConfig = await getDBConfig(); - pool = mysqlPromise.createPool({ + const options: PoolOptions = { ...dbConfig, connectionLimit, multipleStatements: !!( scriptContext && scriptContext.allowMultiStatementSQLQueries ), - }); + }; + pool = mysqlPromise.createPool(options); databaseMonitor = new DatabaseMonitor(pool); return pool; } @@ -144,10 +145,11 @@ async function getMultipleStatementsConnection() { const dbConfig = await getDBConfig(); - return await mysqlPromise.createConnection({ + const options: ConnectionOptions = { ...dbConfig, multipleStatements: true, - }); + }; + return await mysqlPromise.createConnection(options); } export {