Skip to content

Commit

Permalink
fix: fixed typo, fixed max range issue (circular packing)
Browse files Browse the repository at this point in the history
  • Loading branch information
titanism committed Jun 27, 2024
1 parent 776d45d commit 7fd9e4b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions helpers/parse-payload.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const pMap = require('p-map');
const parseErr = require('parse-err');
const pify = require('pify');
const prettyBytes = require('pretty-bytes');
const safeStringify = require('fast-safe-stringify');
const { Iconv } = require('iconv');
const {
S3Client,
Expand Down Expand Up @@ -1289,7 +1290,7 @@ async function parsePayload(data, ws) {
)
},
locals: {
message: `<pre><code>${JSON.stringify(
message: `<pre><code>${safeStringify(
parseErr(err),
null,
2
Expand Down Expand Up @@ -1392,9 +1393,9 @@ async function parsePayload(data, ws) {
} catch (err) {
logger.error(err, { payload });
err.isCodeBug = isCodeBug(err);
// NOTE: since msgpackr supports encode/decode
// errors[`${obj.address}`] = ws ? parseErr(err) : err;
errors[`${obj.address}`] = err;
errors[`${obj.address}`] = JSON.parse(
safeStringify(ws ? parseErr(err) : err)
);
}
},
{ concurrency }
Expand Down Expand Up @@ -2269,9 +2270,9 @@ async function parsePayload(data, ws) {
ws.send(
encoder.pack({
id: payload.id,
err
// err: parseErr(err), // NOTE: results in RangeError: Maximum call stack size exceeded
// err: safeStringify(parseErr(err))
// err, // NOTE: we haven't tried this yet but still it could have a circular reference
err: JSON.parse(safeStringify(parseErr(err)))
})
);
}
Expand Down
2 changes: 1 addition & 1 deletion helpers/setup-pragma.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async function setupPragma(db, session, cipher = 'chacha20') {
db.pragma('secure_delete=ON');

//
// NOTE: we still run a mangal vacuum every 24 hours
// NOTE: we still run a manual vacuum every 24 hours
//
// turn on auto vacuum (for large amounts of deleted content)
// <https://www.sqlite.org/pragma.html#pragma_auto_vacuum>
Expand Down

0 comments on commit 7fd9e4b

Please sign in to comment.