For the record, although I’m able to get the connection to work and I receive initial data, as soon as I query more than a few dozen rows, I get an out of memory error in the server:
events.js:291
throw er; // Unhandled 'error' event
^
error: out of memory
at Connection.parseE (/usr/lib/node_modules/@observablehq/database-proxy/node_modules/pg/lib/connection.js:614:13)
at Connection.parseMessage (/usr/lib/node_modules/@observablehq/database-proxy/node_modules/pg/lib/connection.js:413:19)
at TLSSocket.<anonymous> (/usr/lib/node_modules/@observablehq/database-proxy/node_modules/pg/lib/connection.js:129:22)
at TLSSocket.emit (events.js:314:20)
at TLSSocket.EventEmitter.emit (domain.js:483:12)
at addChunk (_stream_readable.js:298:12)
at readableAddChunk (_stream_readable.js:273:9)
at TLSSocket.Readable.push (_stream_readable.js:214:10)
at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23)
Emitted 'error' event on Pool instance at:
at Client.idleListener (/usr/lib/node_modules/@observablehq/database-proxy/node_modules/pg-pool/index.js:59:10)
at Client.emit (events.js:314:20)
at Client.EventEmitter.emit (domain.js:483:12)
at connectedErrorHandler (/usr/lib/node_modules/@observablehq/database-proxy/node_modules/pg/lib/client.js:202:10)
at Connection.connectedErrorMessageHandler (/usr/lib/node_modules/@observablehq/database-proxy/node_modules/pg/lib/client.js:209:7)
at Connection.emit (events.js:314:20)
at Connection.EventEmitter.emit (domain.js:483:12)
at TLSSocket.<anonymous> (/usr/lib/node_modules/@observablehq/database-proxy/node_modules/pg/lib/connection.js:134:12)
at TLSSocket.emit (events.js:314:20)
at TLSSocket.EventEmitter.emit (domain.js:483:12) {
length: 154,
severity: 'ERROR',
code: '54000',
detail: 'Cannot enlarge string buffer containing 0 bytes by 1130312700 more bytes.',
Apparently Postgres is being asked to process more than 1GB and it’s erroring out. I’ve looked at @visnup 's database-proxy code and the only difference between it and what I do outside of observable (which works) is this call to QueryStream.
I typically just do this:
await client.query(sql)
I’m not sure if that’s the reason, though.