Deno Postgres driver exits silently
cfjello opened this issue · comments
I have written a small example, see below, that shows the problem, at least on my configuration:
- PostgreSQL v12.3 on CloudClusters configured to1500 connections
- deno 1.16.4
- postgres driver: postgres@v0.14.2
- deno std@0.114.0
- vscode Deno language server client v3.9.2
- vscode deno-vscode v0.0..8
- tsc 4.5.2
Output from the test program below:
(....)
5000 Rows Inserted.
TLS connection failed with message: Invalid hostname: '204.2.195.225'
Defaulting to non-encrypted connection
200 Rows Updated.
400 Rows Updated.
600 Rows Updated.
Here the program silently exits.
This problem began, I think, after a 'deno upgrade'.
Also, if I set the 'insertLimit' within the test program to 10001, then even the bulk inserts fails.
Regards,
Claus Fjello-Jensen
----- Program Code ----
import { Client } from "https://deno.land/x/postgres/mod.ts";
//
// Use your own connection details
//
const client = new Client({
user: 'xxxx',
password: 'xxxxxxxx',
database: "xxxx",
hostname: "000.0.000.000",
port: 117,
});
const insertLimit = 5001
await client.connect()
//
// Create
//
let result = await client.queryObject(DROP TABLE LOAD_LIST2
)
if ( result.warnings.length > 0 )
console.log(Delete Table Stmt has warnings: ${JSON.stringify(result.warnings)}
)
else
console.log(Table is deleted.
)
result = await client.queryObject(
CREATE TABLE IF NOT EXISTS LOAD_LIST2 ( ID int GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, filepath VARCHAR(256), started TIMESTAMP NULL, ended TIMESTAMP NULL, success BOOLEAN DEFAULT false )
)
if ( result.warnings.length > 0 )
console.log(Stmt has warnings: ${JSON.stringify(result.warnings)}
)
else
console.log(Table is created.
)
//
// Populate
//
let inserts =[]
for ( let i = 1; i < insertLimit ; i++ ) {
inserts.push( ( DEFAULT, 'fileName_${i}', NULL, NULL, FALSE )
)
if ( i % 200 === 0 ) {
await client.queryObject( 'INSERT INTO load_list2 VALUES ' + inserts.join(',') )
inserts = []
console.log(${i} Rows Inserted.
)
}
}
await client.end()
//
// Test
//
await client.connect()
for ( let i = 1; i < insertLimit; i++ ) {
try {
result = await client.queryObject(UPDATE load_list2 SET started = now() WHERE id = ${i}
)
if ( result.warnings.length > 0 )
console.log(Stmt has warnings: ${JSON.stringify(result.warnings)}
)
if ( i % 200 === 0 ) console.log(${i} Rows Updated.
)
}
catch(err) {
console.log(Update failed at: ${i}
)
}
}
await client.end()
I downgraded Deno using: deno upgrade --version 1.3.0, and now the test program works and runs without exiting. So whatever problem this is, it is introduced by Deno - but it still leaves the issue of capturing the Error.
Quite possibly caused by https://bugs.chromium.org/p/v8/issues/detail?id=12444&q=Type%3D%22Bug%22
Will be fixed upstream once V8 releases a new version and Deno upgrades. However since this is a panic there is no way to catching that on the program's end in the meanwhile
I'll leave this issue open in the meanwhile
@cfjello This will be fixed once Deno 1.18.0 is released denoland/deno#12940 (comment)
I have now installed Deno 1.18.0 and can verify, that my test program now runs without any problem. Thanks for your help!