Next.js Discord

Discord Forum

API Data Fetching Limits

Unanswered
Satin Angora posted this in #help-forum
Open in Discord
Satin AngoraOP
I am working on an energy monitoring system, and I need to fetch a large amount of data containing thousands of documents from MongoDB. However, I believe there may be a limitation. When I attempt to fetch monthly data, it shows an error. Can anyone help me with this issue?

10 Replies

Could you please share the error message you got?
Satin AngoraOP
It takes almost 5 minutes to execute the query :
const meter = await collection.find().toArray();
and then shows this error.
but when i try to limit the data by adding start data and end date then it works perfectly fine.
Head over to the terminal that you run Next.js server, then check the output. You would see more details about the error.
Satin AngoraOP
at async Server.<anonymous> (C:) {
cause: HeadersTimeoutError: Headers Timeout Error
at Timeout.onParserTimeout [as callback] (C:energy-system\node_modules\next\dist\compiled\undici\index.js:1:62578)
at Timeout.onTimeout [as _onTimeout] (Cnergy-system\node_modules\next\dist\compiled\undici\index.js:2:269659)
at listOnTimeout (node:internal/timers:569:17)
at process.processTimers (node:internal/timers:512:7) {
code: 'UND_ERR_HEADERS_TIMEOUT'
}
}
here is the terminal output
ur name is exposed in the log directory path.
Satin AngoraOP
Kindly tell me if you have any idea how to resolve this issue?
as you said, it is due to timeout error of MongoDB connection. so extending timeout setting of MongoDB connection would work.
im not sure how to do that, when googling it, i found something like this

https://stackoverflow.com/questions/39087570/mongodb-timeout-issue-node-js
Satin AngoraOP
ok,Thanks for your time and guidance.