Skip to content

Install and test client using Bun #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
26 changes: 23 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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
}
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
In the next release ...

- Fix issue handling connection error during secure startup.

1.8.0 (2023-12-14)
------------------

Expand Down
5 changes: 1 addition & 4 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down