Skip to content

Commit

Permalink
fix(workaround): RangeError: Invalid string length
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshinorin committed Apr 12, 2022
1 parent c84e59e commit 84e62d4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const WarehouseError = require('./error');
const pkg = require('../package.json');
const { open } = fs.promises;
const pipeline = Promise.promisify(require('stream').pipeline);
const log = require('hexo-log')();

let _writev;

Expand Down Expand Up @@ -53,6 +54,14 @@ async function exportAsync(database, path) {

// End models
await handle.write('}}');
} catch(e) {
log.error(e);
if (RangeError instanceof e && e.message.contains("Invalid string length")) {
// NOTE: Currently we can't do anymore this issue.
log.warn("see: https://github.com/nodejs/node/issues/35973");
} else {
throw e;
}
} finally {
await handle.close();
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
"author": "Tommy Chen <tommy351@gmail.com> (http://zespia.tw)",
"license": "MIT",
"dependencies": {
"JSONStream": "^1.0.7",
"bluebird": "^3.2.2",
"cuid": "^2.1.4",
"graceful-fs": "^4.1.3",
"hexo-log": "^3.0.0",
"is-plain-object": "^5.0.0",
"JSONStream": "^1.0.7",
"rfdc": "^1.1.4"
},
"devDependencies": {
Expand Down

0 comments on commit 84e62d4

Please sign in to comment.