Skip to content

Commit

Permalink
Merge pull request #17 from supabase-community/fix/pglite-error-hang
Browse files Browse the repository at this point in the history
Add test for PGlite hanging after error message
  • Loading branch information
gregnr authored Sep 23, 2024
2 parents 561fa36 + 87f2096 commit 0ed68f0
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 12 deletions.
13 changes: 6 additions & 7 deletions deno.lock

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

2 changes: 1 addition & 1 deletion examples/pglite-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type-check": "tsc --noEmit"
},
"dependencies": {
"@electric-sql/pglite": "^0.2.6",
"@electric-sql/pglite": "^0.2.7",
"pg-gateway": "*"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/pglite-multiple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"type-check": "tsc --noEmit"
},
"dependencies": {
"@electric-sql/pglite": "^0.2.6",
"@electric-sql/pglite": "^0.2.7",
"pg-gateway": "*"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion packages/pg-gateway/test/deno/tcp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import pg from 'npm:pg';

import { expect } from 'jsr:@std/expect';
import { afterAll, beforeAll, describe, it } from 'jsr:@std/testing/bdd';
import { PGlite } from 'npm:@electric-sql/pglite';
import { PGlite } from 'npm:@electric-sql/pglite@^0.2.7';
import { fromDenoConn } from 'pg-gateway/deno';

const { Client } = pg;
Expand Down
11 changes: 11 additions & 0 deletions packages/pg-gateway/test/node/pg.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,15 @@ describe('pg client with pglite', () => {
const [{ message }] = res.rows;
expect(message).toBe('Hello world!');
});

it('invalid sql throws an error but does not hang', async () => {
await using client = await connect();
const promise = client.query('invalid sql');
await expect(promise).rejects.toThrowError('syntax error at or near "invalid"');

// Run another query to see if the connection hung
const res = await client.query("select 'Hello world!' as message");
const [{ message }] = res.rows;
expect(message).toBe('Hello world!');
});
});

0 comments on commit 0ed68f0

Please sign in to comment.