Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: gajus/slonik
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v34.0.0
Choose a base ref
...
head repository: gajus/slonik
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v34.0.1
Choose a head ref
  • 1 commit
  • 5 files changed
  • 1 contributor

Commits on Jun 7, 2023

  1. fix: remove p-defer

    gajus committed Jun 7, 2023
    Copy the full SHA
    128e4c5 View commit details
Showing with 21 additions and 15 deletions.
  1. +0 −9 package-lock.json
  2. +0 −1 package.json
  3. +3 −3 src/routines/executeQuery.ts
  4. +2 −2 src/state.ts
  5. +16 −0 src/utilities/defer.ts
9 changes: 0 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"concat-stream": "^2.0.0",
"es6-error": "^4.1.1",
"iso8601-duration": "^1.3.0",
"p-defer": "^3.0.0",
"pg": "^8.11.0",
"pg-cursor": "^2.10.0",
"pg-protocol": "^1.6.0",
6 changes: 3 additions & 3 deletions src/routines/executeQuery.ts
Original file line number Diff line number Diff line change
@@ -26,8 +26,8 @@ import {
type QuerySqlToken,
} from '../types';
import { createQueryId } from '../utilities/createQueryId';
import { defer } from '../utilities/defer';
import { getStackTrace } from '../utilities/getStackTrace';
import Deferred from 'p-defer';
import { type PoolClient as PgPoolClient } from 'pg';
import { serializeError } from 'serialize-error';

@@ -211,7 +211,7 @@ export const executeQuery = async (
notices.push(notice);
};

const activeQuery = Deferred();
const activeQuery = defer<null>();

const blockingPromise = poolClientState.activeQuery?.promise ?? null;

@@ -328,7 +328,7 @@ export const executeQuery = async (
} finally {
connection.off('notice', noticeListener);

activeQuery.resolve();
activeQuery.resolve(null);
}
} catch (error) {
for (const interceptor of clientConfiguration.interceptors) {
4 changes: 2 additions & 2 deletions src/state.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { UnexpectedStateError } from './errors';
import { type TypeOverrides } from './types';
import { type DeferredPromise } from 'p-defer';
import { type DeferredPromise } from './utilities/defer';
import { type Pool as PgPool, type PoolClient as PgClientPool } from 'pg';

type PoolState = {
@@ -11,7 +11,7 @@ type PoolState = {
};

type PoolClientState = {
activeQuery?: DeferredPromise<unknown>;
activeQuery?: DeferredPromise<null>;
connectionId: string;
mock: boolean;
poolId: string;
16 changes: 16 additions & 0 deletions src/utilities/defer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export type DeferredPromise<ValueType> = {
promise: Promise<ValueType>;
reject: (error: unknown) => void;
resolve: (value: ValueType) => void;
};

export const defer = <T>(): DeferredPromise<T> => {
const deferred = {} as DeferredPromise<T>;

deferred.promise = new Promise((resolve, reject) => {
deferred.resolve = resolve;
deferred.reject = reject;
});

return deferred;
};