【发布时间】:2021-06-19 03:27:57
【问题描述】:
今天我在他的控制台中收到了两次错误消息,只有重新启动后端才能解决它。我将 Node/expressjs 用于后端,将 reactjs 用于前端。后端服务于两个网站(管理员和客户端),它会导致这种错误吗?还是我只需要在 mongodb 上购买高级集群?也许只是那里没有可用空间了。请帮我弄清楚如何解决它。谢谢!
[9860:000001FB55904120] 6734212 ms: Scavenge 23.8 (28.2) -> 23.1 (29.2) MB, 2.8 / 0.0 ms (average mu = 0.999, current mu = 1.000) allocation failure
[9860:000001FB55904120] 6734237 ms: Scavenge 23.8 (28.2) -> 23.2 (29.2) MB, 4.8 / 0.0 ms (average mu = 0.999, current mu = 1.000) allocation failure
[9860:000001FB55904120] 6734552 ms: Scavenge 24.1 (28.2) -> 23.4 (29.2) MB, 6.3 / 0.0 ms (average mu = 0.999, current mu = 1.000) allocation failure
<--- JS stacktrace --->
FATAL ERROR: Committing semi space failed. Allocation failed - JavaScript heap out of memory
1: 00007FF60314052F napi_wrap+109311
2: 00007FF6030E5256 v8::internal::OrderedHashTable<v8::internal::OrderedHashSet,1>::NumberOfElementsOffset+33302
3: 00007FF6030E6026 node::OnFatalError+294
4: 00007FF6039B163E v8::Isolate::ReportExternalAllocationLimitReached+94
5: 00007FF6039964BD v8::SharedArrayBuffer::Externalize+781
6: 00007FF60384094C v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1516
7: 00007FF603848E9F v8::internal::Heap::PageFlagsAreConsistent+2559
8: 00007FF60383DA61 v8::internal::Heap::CollectGarbage+2033
9: 00007FF60383BC65 v8::internal::Heap::AllocateExternalBackingStore+1317
10: 00007FF60385C057 v8::internal::Factory::NewFillerObject+183
11: 00007FF60358C0B1 v8::internal::interpreter::JumpTableTargetOffsets::iterator::operator=+1409
12: 00007FF603A39FED v8::internal::SetupIsolateDelegate::SetupHeap+463949
13: 00000343072A216B
[nodemon] app crashed - waiting for file changes before starting...
这是错误发生前的请求:
POST /api/8547685765867gurhgfbgjbfgngbgjhtiu5895785hefjsfsfGGGGGGGGGGGGGGGGGGGGGGGGGGG847389jnem/admin/articlesaweek - - ms - -
这是路由器:
router.post("/" + process.env.HASHFORADMIN +"/admin/articlesaweek", async (req, res) => {
res.send(await adminactions.articlesInAWeek(req, res))
})
这是控制器的功能
articlesInAWeek : async (req, res) => {
const data = [ (await Article.find({date: { $gt: new Date((new Date( )).getFullYear(),
new Date().getMonth(),
new Date(Date.now()).getDay()
)}})).length, (await Article.find({date: { $gt: new Date((new Date( )).getFullYear(),
new Date().getMonth(),
new Date(Date.now()).getDay() - 1
)}})).length, (await Article.find({date: { $gt: new Date((new Date( )).getFullYear(),
new Date().getMonth(),
new Date(Date.now()).getDay() - 2
)}})).length, (await Article.find({date: { $gt: new Date((new Date( )).getFullYear(),
new Date().getMonth(),
new Date(Date.now()).getDay() - 3
)}})).length,
(await Article.find({date: { $gt: new Date((new Date( )).getFullYear(),
new Date().getMonth(),
new Date(Date.now()).getDay() - 4
)}})).length,
(await Article.find({date: { $gt: new Date((new Date( )).getFullYear(),
new Date().getMonth(),
new Date(Date.now()).getDay() - 5
)}})).length,
(await Article.find({date: { $gt: new Date((new Date( )).getFullYear(),
new Date().getMonth(),
new Date(Date.now()).getDay() - 6
)}})).length
];
return data;
},
【问题讨论】:
标签: javascript node.js database mongodb express