diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d145308..40d9e7d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -46,9 +46,13 @@ jobs: - type: node version: 18.x - type: node + version: 20.x + - type: bun runs-on: ubuntu-latest timeout-minutes: 3 steps: + - run: sudo apt-get update + - run: sudo apt-get install zsh - run: | function set() { docker exec ${{ job.services.postgres.id }} sh -c "echo $1=\'$2\' >> $PGDATADIR/postgresql.conf" @@ -66,6 +70,9 @@ jobs: uses: actions/setup-node@v3 with: node-version: ${{ matrix.environment.version }} + - name: Use Bun ${{ matrix.environment.version }} + if: matrix.environment.type == 'bun' + uses: oven-sh/setup-bun@v1 - name: Install dependencies if: matrix.environment.type == 'node' run: npm ci @@ -89,8 +96,8 @@ jobs: cat <<- EOF import { Client } from '$1'; const client = new Client(); - const secured = await client.connect(); - console.log(secured); + const info = await client.connect(); + console.log("Encrypted: " + info.encrypted); await client.end(); EOF } @@ -100,9 +107,22 @@ jobs: npm run test:prod || exit 1 npm run build gen_code ./dist/src/index.js > test.mjs - node test.mjs | tee /dev/stderr | grep -q true + node test.mjs | tee /dev/stderr | grep true + ;; + bun) + # Workaround: https://github.com/oven-sh/bun/issues/1590 + set -x + TRAPERR() print -u2 Exit status: $? + dependencies=`jq -r '.dependencies|to_entries|map("\(.key)@\(.value)")|join(" ")' package.json` + ( mkdir /tmp/bun && cd "$_" && ls -lah && bun install "$dependencies" && rm -rf `pwd`; ) + bun install -p --ignore-scripts + bun build src/index.ts --target bun > ts-postgres.js + gen_code ./ts-postgres.js > test.mjs + bun test.mjs + bun test.mjs | tee /dev/stderr | grep true ;; esac + shell: zsh {0} env: ENVIRONMENT: ${{ matrix.environment.type }} NODE_EXTRA_CA_CERTS: ssl-cert-snakeoil.pem diff --git a/CHANGES.md b/CHANGES.md index 2e42dae..413f309 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,7 @@ +In the next release ... + +- Fix issue handling connection error during secure startup. + 1.8.0 (2023-12-14) ------------------ diff --git a/src/client.ts b/src/client.ts index d1e8199..2cf15e0 100644 --- a/src/client.ts +++ b/src/client.ts @@ -278,11 +278,8 @@ export class Client { writer.startupSSL(); const abort = (error: Error) => { - if (!this.handleError(error)) { - throw new Error("Internal error occurred while establishing connection"); - } + this.handleError(error); this.events.connect.emit(error); - this.end(); } const startup = (stream?: Socket) => {