-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
pg-protocol can throw an uncatchable error "Cannot create a string longer than 0x1fffffe8 characters" when reading large data #2653
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
Comments
I think it may be related to this TODO here, as it's try to read as UTF-8 a binary blob:
And somewhat related is why does it try to read all fields as strings, even when it's a binary blob:
|
The PostgreSQL wire protocol has two modes for transferring fields: text and binary The text mode is a string representation of each data type, such as "1234" to represent the number 1234 or "t" to represent the value true. The binary is more compact but is not documented anywhere outside of the server source. This driver only supports reading the text mode and that class only handles text format responses:
This is still a bug though as throwing uncatchable internal errors is never acceptable. If those long values cannot be deserialized as a string then there should be a length check and a proper error message bubbled up rather than crashing. Even when this is fixed you likely don't want to ship that much data back and forth in one piece. There's many other options including reading slices of the data as slicing into smaller bytea or using the large object API (https://www.postgresql.org/docs/current/lo-funcs.html). |
yah definitely a bug, uncatchable errors are always no bueno. I'll try to
get this fixed. Everything @sehrope said is 👍 as always as well. ❤️
…On Sun, Nov 14, 2021 at 9:50 AM Sehrope Sarkuni ***@***.***> wrote:
And somewhat related is why does it try to read all fields as strings,
even when it's a binary blob:
The PostgreSQL wire protocol has two modes for transferring fields: text
and binary
The text mode is a string representation of each data type, such as "1234"
to represent the number 1234 or "t" to represent the value true. The binary
is more compact but is not documented anywhere outside of the server source.
This driver only supports reading the text mode and that class only
handles text format responses:
https://github.com/brianc/node-postgres/blob/947ccee346f0d598e135548e1e4936a9a008fc6f/packages/pg-protocol/src/parser.ts#L87
Any idea what might be the issue and how to fix it?
This is still a bug though as throwing uncatchable internal errors is
never acceptable. If those long values cannot be deserialized as a string
then there should be a length check and a proper error message bubbled up
rather than crashing.
Even when this is fixed you likely don't want to ship that much data back
and forth in one piece. There's many other options including reading slices
of the data as slicing into smaller bytea or using the large object API (
https://www.postgresql.org/docs/current/lo-funcs.html).
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2653 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAMHION47SFXFHZK354I5LUL7LCXANCNFSM5H723XBQ>
.
|
npm run serve
INFO Starting development server... Error: Cannot create a string longer than 0x1fffffe8 characters What is the problem with my Vuejs old project? It is not running. |
Is it not clear from the thread above that you, presumably, just read? |
any updates on this bug fix? With the latest version, there is still uncatchable error with large query result. thanks |
Just ran into this with v8.8.0. Hopefully there's a way to avoid converting big (> 250MB) binary fields into javascript Strings. |
Exception occuring within the handlePacket will bubble up to pg as uncatchables exceptions errors. Adding a try/catch and returning an handled error allow the caller program to catch such exceptions and decide what to do with them. Fixes brianc#2653
Exception occuring within the handlePacket will bubble up to pg as uncatchables exceptions errors. Adding a try/catch and returning an handled error allow the caller program to catch such exceptions and decide what to do with them. Fixes brianc#2653
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:
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:node-postgres/packages/pg-protocol/src/index.ts
Line 5 in 947ccee
Any idea what might be the issue and how to fix it?
The text was updated successfully, but these errors were encountered: