kober
14 November 2021 10:51
1
I get 502 Bad Gateway when syncing, and also on the joplin cloud login page.
Yes sorry about that, it's back up now. Some unexpected error that unfortunately brought down the server. I'm going to check how to prevent it in the furture.
2 Likes
I found the issue although it will be tricky to fix since this is an upstream bug in the Postgres database driver:
opened 01:08PM - 14 Nov 21 UTC
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:
https://github.com/brianc/node-postgres/blob/947ccee346f0d598e135548e1e4936a9a008fc6f/packages/pg-protocol/src/index.ts#L5
Any idea what might be the issue and how to fix it?
In the meantime I will mitigate the issue by preventing large objects from being uploaded or downloaded. Thankfully only two items are affected and the issue will be resolved once we move to S3 for storage.
1 Like
system
Closed
14 December 2021 16:16
4
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.