Description
Using the "pg" package 8.5.1
To replicate the issue, save some large data as a blob into the database. In my case 340 MB was enough to trigger the bug. Then try to read back the data.
It will throw this uncatchable error that crashes the application:
Error: Cannot create a string longer than 0x1fffffe8 characters
at Buffer.utf8Slice (<anonymous>)
at Object.slice (node:buffer:593:37)
at Buffer.toString (node:buffer:811:14)
at BufferReader.string (/home/joplin/packages/server/node_modules/pg-protocol/src/buffer-reader.ts:35:32)
at Parser.parseDataRowMessage (/home/joplin/packages/server/node_modules/pg-protocol/src/parser.ts:274:51)
at Parser.handlePacket (/home/joplin/packages/server/node_modules/pg-protocol/src/parser.ts:172:21)
at Parser.parse (/home/joplin/packages/server/node_modules/pg-protocol/src/parser.ts:101:30)
at Socket.<anonymous> (/home/joplin/packages/server/node_modules/pg-protocol/src/index.ts:7:48)
at Socket.emit (node:events:390:28)
at addChunk (node:internal/streams/readable:315:12)
As a test I've tried to make it reject the promise when parser.parse(buffer, callback)
throws an error in this function. At that time I can indeed catch the error, but rejecting the promise properly doesn't help for some reason and the error is still uncatchable:
Any idea what might be the issue and how to fix it?