React 项目在 Heroku 上因许多分配失败而崩溃,但在本地开发上运行
React project crashes with many allocation failures on Heroku but runs on local dev
我的 React 日历应用程序在本地开发版本上运行良好,但在部署到 Heroku 时出现许多分配失败。
这是来自 Heroku 日志的错误:
2021-08-29T06:50:16.143215+00:00 app[web.1]: <--- Last few GCs --->
2021-08-29T06:50:16.143216+00:00 app[web.1]:
2021-08-29T06:50:16.143232+00:00 app[web.1]: [29:0x59b3ba0] 23626 ms: Mark-sweep (reduce) 253.6 (257.1) -> 251.9 (258.6) MB, 22.3 / 0.0 ms (+ 868.9 ms in 46 steps since start of marking, biggest step 759.6 ms, walltime since start of marking 919 ms) (average mu = 0.240, current mu = 0.080) alloc[29:0x59b3ba0] 23886 ms: Mark-sweep (reduce) 253.0 (257.6) -> 252.4 (258.1) MB, 255.2 / 0.0 ms (average mu = 0.193, current mu = 0.018) allocation failure scavenge might not succeed
2021-08-29T06:50:16.143232+00:00 app[web.1]:
2021-08-29T06:50:16.143233+00:00 app[web.1]:
2021-08-29T06:50:16.143233+00:00 app[web.1]: <--- JS stacktrace --->
2021-08-29T06:50:16.143233+00:00 app[web.1]:
2021-08-29T06:50:16.143238+00:00 app[web.1]: FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memory
2021-08-29T06:50:16.143807+00:00 app[web.1]: 1: 0xa25510 node::Abort() [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.144226+00:00 app[web.1]: 2: 0x9664d3 node::FatalError(char const*, char const*) [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.144703+00:00 app[web.1]: 3: 0xb9a8be v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.145191+00:00 app[web.1]: 4: 0xb9ac37 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.145733+00:00 app[web.1]: 5: 0xd56ca5 [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.146333+00:00 app[web.1]: 6: 0xd8763e v8::internal::EvacuateNewSpaceVisitor::Visit(v8::internal::HeapObject, int) [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.146849+00:00 app[web.1]: 7: 0xd93676 v8::internal::FullEvacuator::RawEvacuatePage(v8::internal::MemoryChunk*, long*) [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.147462+00:00 app[web.1]: 8: 0xd7f80f v8::internal::Evacuator::EvacuatePage(v8::internal::MemoryChunk*) [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.148027+00:00 app[web.1]: 9: 0xd7fa88 v8::internal::PageEvacuationTask::RunInParallel(v8::internal::ItemParallelJob::Task::Runner) [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.148593+00:00 app[web.1]: 10: 0xd72369 v8::internal::ItemParallelJob::Run() [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.149156+00:00 app[web.1]: 11: 0xd955d0 void v8::internal::MarkCompactCollectorBase::CreateAndExecuteEvacuationTasks<v8::internal::FullEvacuator, v8::internal::MarkCompactCollector>(v8::internal::MarkCompactCollector*, v8::internal::ItemParallelJob*, v8::internal::MigrationObserver*, long) [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.149712+00:00 app[web.1]: 12: 0xd95e6c v8::internal::MarkCompactCollector::EvacuatePagesInParallel() [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.150265+00:00 app[web.1]: 13: 0xd96035 v8::internal::MarkCompactCollector::Evacuate() [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.150813+00:00 app[web.1]: 14: 0xda8031 v8::internal::MarkCompactCollector::CollectGarbage() [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.151369+00:00 app[web.1]: 15: 0xd642f8 v8::internal::Heap::MarkCompact() [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.151930+00:00 app[web.1]: 16: 0xd65de8 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.152498+00:00 app[web.1]: 17: 0xd6922c v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.153042+00:00 app[web.1]: 18: 0xd3790b v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.153673+00:00 app[web.1]: 19: 0x107fbef v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.154370+00:00 app[web.1]: 20: 0x1426919 [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.182810+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-08-29T06:50:16.182987+00:00 app[web.1]: npm ERR! errno 1
2021-08-29T06:50:16.186047+00:00 app[web.1]: npm ERR! meeting-scheduler-frontend@0.1.0 start: `react-scripts start`
2021-08-29T06:50:16.186119+00:00 app[web.1]: npm ERR! Exit status 1
2021-08-29T06:50:16.186179+00:00 app[web.1]: npm ERR!
2021-08-29T06:50:16.186220+00:00 app[web.1]: npm ERR! Failed at the meeting-scheduler-frontend@0.1.0 start script.
2021-08-29T06:50:16.186261+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
我的项目代码位于:https://github.com/innext/meetingSchedulerReact.git
问题出在 Heroku
部署 React 应用程序的方式上。通常,当 运行 一个客户端反应应用程序被服务时,我们首先构建然后服务构建。
在这种情况下,Heroku
不知道如何构建 React 应用程序,因此它假定它是一个 Node.js
应用程序。
要解决此问题,您必须更改 Heroku
中的构建包,它位于“构建包”部分下的“设置”选项卡上。这是 React 构建包 https://github.com/mars/create-react-app-buildpack.git。复制并粘贴然后重新部署。如果不起作用,还可以搜索更多的反应构建包。
如果您不喜欢麻烦并希望有人自动为您处理事情,您可以使用像 Netlify
这样的平台,默认情况下它会为您处理所有这些事情。
我的 React 日历应用程序在本地开发版本上运行良好,但在部署到 Heroku 时出现许多分配失败。
这是来自 Heroku 日志的错误:
2021-08-29T06:50:16.143215+00:00 app[web.1]: <--- Last few GCs --->
2021-08-29T06:50:16.143216+00:00 app[web.1]:
2021-08-29T06:50:16.143232+00:00 app[web.1]: [29:0x59b3ba0] 23626 ms: Mark-sweep (reduce) 253.6 (257.1) -> 251.9 (258.6) MB, 22.3 / 0.0 ms (+ 868.9 ms in 46 steps since start of marking, biggest step 759.6 ms, walltime since start of marking 919 ms) (average mu = 0.240, current mu = 0.080) alloc[29:0x59b3ba0] 23886 ms: Mark-sweep (reduce) 253.0 (257.6) -> 252.4 (258.1) MB, 255.2 / 0.0 ms (average mu = 0.193, current mu = 0.018) allocation failure scavenge might not succeed
2021-08-29T06:50:16.143232+00:00 app[web.1]:
2021-08-29T06:50:16.143233+00:00 app[web.1]:
2021-08-29T06:50:16.143233+00:00 app[web.1]: <--- JS stacktrace --->
2021-08-29T06:50:16.143233+00:00 app[web.1]:
2021-08-29T06:50:16.143238+00:00 app[web.1]: FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memory
2021-08-29T06:50:16.143807+00:00 app[web.1]: 1: 0xa25510 node::Abort() [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.144226+00:00 app[web.1]: 2: 0x9664d3 node::FatalError(char const*, char const*) [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.144703+00:00 app[web.1]: 3: 0xb9a8be v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.145191+00:00 app[web.1]: 4: 0xb9ac37 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.145733+00:00 app[web.1]: 5: 0xd56ca5 [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.146333+00:00 app[web.1]: 6: 0xd8763e v8::internal::EvacuateNewSpaceVisitor::Visit(v8::internal::HeapObject, int) [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.146849+00:00 app[web.1]: 7: 0xd93676 v8::internal::FullEvacuator::RawEvacuatePage(v8::internal::MemoryChunk*, long*) [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.147462+00:00 app[web.1]: 8: 0xd7f80f v8::internal::Evacuator::EvacuatePage(v8::internal::MemoryChunk*) [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.148027+00:00 app[web.1]: 9: 0xd7fa88 v8::internal::PageEvacuationTask::RunInParallel(v8::internal::ItemParallelJob::Task::Runner) [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.148593+00:00 app[web.1]: 10: 0xd72369 v8::internal::ItemParallelJob::Run() [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.149156+00:00 app[web.1]: 11: 0xd955d0 void v8::internal::MarkCompactCollectorBase::CreateAndExecuteEvacuationTasks<v8::internal::FullEvacuator, v8::internal::MarkCompactCollector>(v8::internal::MarkCompactCollector*, v8::internal::ItemParallelJob*, v8::internal::MigrationObserver*, long) [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.149712+00:00 app[web.1]: 12: 0xd95e6c v8::internal::MarkCompactCollector::EvacuatePagesInParallel() [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.150265+00:00 app[web.1]: 13: 0xd96035 v8::internal::MarkCompactCollector::Evacuate() [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.150813+00:00 app[web.1]: 14: 0xda8031 v8::internal::MarkCompactCollector::CollectGarbage() [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.151369+00:00 app[web.1]: 15: 0xd642f8 v8::internal::Heap::MarkCompact() [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.151930+00:00 app[web.1]: 16: 0xd65de8 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.152498+00:00 app[web.1]: 17: 0xd6922c v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.153042+00:00 app[web.1]: 18: 0xd3790b v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.153673+00:00 app[web.1]: 19: 0x107fbef v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.154370+00:00 app[web.1]: 20: 0x1426919 [/app/.heroku/node/bin/node]
2021-08-29T06:50:16.182810+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-08-29T06:50:16.182987+00:00 app[web.1]: npm ERR! errno 1
2021-08-29T06:50:16.186047+00:00 app[web.1]: npm ERR! meeting-scheduler-frontend@0.1.0 start: `react-scripts start`
2021-08-29T06:50:16.186119+00:00 app[web.1]: npm ERR! Exit status 1
2021-08-29T06:50:16.186179+00:00 app[web.1]: npm ERR!
2021-08-29T06:50:16.186220+00:00 app[web.1]: npm ERR! Failed at the meeting-scheduler-frontend@0.1.0 start script.
2021-08-29T06:50:16.186261+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
我的项目代码位于:https://github.com/innext/meetingSchedulerReact.git
问题出在 Heroku
部署 React 应用程序的方式上。通常,当 运行 一个客户端反应应用程序被服务时,我们首先构建然后服务构建。
在这种情况下,Heroku
不知道如何构建 React 应用程序,因此它假定它是一个 Node.js
应用程序。
要解决此问题,您必须更改 Heroku
中的构建包,它位于“构建包”部分下的“设置”选项卡上。这是 React 构建包 https://github.com/mars/create-react-app-buildpack.git。复制并粘贴然后重新部署。如果不起作用,还可以搜索更多的反应构建包。
如果您不喜欢麻烦并希望有人自动为您处理事情,您可以使用像 Netlify
这样的平台,默认情况下它会为您处理所有这些事情。