Skip to content
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

JSON Server Not Loading with 700 MB JSON File #529

Open
ilovmylord opened this issue May 1, 2017 · 5 comments
Open

JSON Server Not Loading with 700 MB JSON File #529

ilovmylord opened this issue May 1, 2017 · 5 comments

Comments

@ilovmylord
Copy link

Hi All,

We have a JSON File which is around 700 MB.
We are trying to restart JSON Server with watching this file.
An error is thrown as below

buffer.js:496
throw new Error(‘“toString()” failed’);
^

Error: “toString()” failed
at Buffer.toString (buffer.js:496:11)
at Object.fs.readFileSync (fs.js:553:33)
at Object.read (/usr/local/lib/node_modules/json-server/node_modules/lowdb/lib/file-sync.js:15:21)
at LodashWrapper.db.read (/usr/local/lib/node_modules/json-server/node_modules/lowdb/lib/_index.js:36:29)
at module.exports (/usr/local/lib/node_modules/json-server/node_modules/lowdb/lib/_index.js:96:15)
at low (/usr/local/lib/node_modules/json-server/node_modules/lowdb/lib/index.node.js:12:10)
at module.exports (/usr/local/lib/node_modules/json-server/lib/cli/utils/load.js:36:17)
at start (/usr/local/lib/node_modules/json-server/lib/cli/run.js:119:5)
at module.exports (/usr/local/lib/node_modules/json-server/lib/cli/run.js:156:3)
at module.exports (/usr/local/lib/node_modules/json-server/lib/cli/index.js:76:3)

@ilovmylord ilovmylord changed the title JSON Server Not Loading with JSON File JSON Server Not Loading with 700 MB JSON File May 10, 2017
@ilovmylord
Copy link
Author

Hey @typicode ,

We are stuck here . Please help

@typicode
Copy link
Owner

Hi,

Sorry for delay. 700MB is quite big for a JSON file and Node fs.writeFileSync seems to fail converting it to a string (maybe related nodejs/node#9489)

I would try reducing the size of the file by removing all the data that you don't need to be mocked.
To quickly check if your file is small enough, you can run the following code and see if it works:

const fs = require('fs')
const string = fs.readFileSync('db.json', 'utf-8')
JSON.parse(string)

You may want to try passing options to Node to increase some of the limits (not sure it would solve everything though)

@ziziermao
Copy link

May I ask if this is resolved? We are facing the same problem too.

@ziziermao
Copy link

We are using requests.js, one response is pretty large.

@ahmedabbas11
Copy link

any updates regrading this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants