Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions packages/cubejs-jdbc-driver/src/JDBCDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ import { promisify } from 'util';
import genericPool, { Factory, Pool } from 'generic-pool';
import path from 'path';

import { DriverOptionsInterface, SupportedDrivers } from './supported-drivers';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { JDBCDriverConfiguration } from './types';
import { QueryStream, nextFn, Row, transformRow } from './QueryStream';
import { SupportedDrivers } from './supported-drivers';
import type { DriverOptionsInterface } from './supported-drivers';
import type { JDBCDriverConfiguration } from './types';
import { QueryStream, transformRow } from './QueryStream';
import type { nextFn } from './QueryStream';

/* eslint-disable no-restricted-syntax,import/no-extraneous-dependencies */
const DriverManager = require('@cubejs-backend/jdbc/lib/drivermanager');
Expand Down Expand Up @@ -147,8 +148,7 @@ export class JDBCDriver extends BaseDriver {
const getConnection = promisify(DriverManager.getConnection.bind(DriverManager));
return new Connection(await getConnection(this.config.url, this.jdbcProps));
},
// @ts-expect-error Promise<Function> vs Promise<void>
destroy: async (connection) => promisify(connection.close.bind(connection)),
destroy: async (connection) => promisify(connection.close.bind(connection))(),
validate: async (connection) => (
new Promise((resolve) => {
const isValid = promisify(connection.isValid.bind(connection));
Expand Down Expand Up @@ -183,6 +183,14 @@ export class JDBCDriver extends BaseDriver {
acquireTimeoutMillis: 120000,
...(poolOptions || {})
}) as ExtendedPool;

// https://github.com/coopernurse/node-pool/blob/ee5db9ddb54ce3a142fde3500116b393d4f2f755/README.md#L220-L226
this.pool.on('factoryCreateError', (err) => {
this.databasePoolError(err);
});
this.pool.on('factoryDestroyError', (err) => {
this.databasePoolError(err);
});
}

protected async getCustomClassPath() {
Expand Down
1 change: 1 addition & 0 deletions packages/cubejs-testing-drivers/src/helpers/getDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export async function getDriver(type: string): Promise<{
return import(`@cubejs-backend/${type}-driver`).then((module) => {
// eslint-disable-next-line new-cap
const source: BaseDriver = new module.default();
source.setLogger((msg: unknown, event: unknown) => console.log(`${msg}: ${JSON.stringify(event)}`));
const storage = new CubeStoreDriver();
return { source, storage };
});
Expand Down
Loading