Heroku - JavaScript 堆内存不足

Heroku - JavaScript heap out of memory

我能够 运行 在本地毫无问题地运行我的 React 应用程序,但是当我将应用程序部署到 heroku 时,我遇到了 OOM 错误。这不是我第一次部署该应用程序,但这次我添加了 OKTA 身份验证,这显然会导致此问题。任何有关如何解决此问题的建议将不胜感激。

*2021-06-12T08:20:28.956656+00:00 app[web.1]: []    50712 ms: Scavenge (reduce) 253.4 (257.4) -> 253.1 (257.7) MB, 32.0 / 0.0 ms  (average mu = 0.729, current mu = 0.667) allocation failure 
2021-06-12T08:20:28.956657+00:00 app[web.1]: []    51247 ms: Mark-sweep (reduce) 253.7 (256.7) -> 252.2 (258.4) MB, 430.7 / 0.0 ms  (+ 79.5 ms in 19 steps since start of marking, biggest step 29.6 ms, walltime since start of marking 627 ms) (average mu = 0.583, current mu = 0.254) alloca
2021-06-12T08:20:28.956657+00:00 app[web.1]: 
2021-06-12T08:20:28.956657+00:00 app[web.1]: <--- JS stacktrace --->
2021-06-12T08:20:28.956658+00:00 app[web.1]: 
2021-06-12T08:20:28.956667+00:00 app[web.1]: FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memory
2021-06-12T08:20:28.957512+00:00 app[web.1]:  1: node::Abort() [/app/.heroku/node/bin/node]
2021-06-12T08:20:28.958078+00:00 app[web.1]:  2: node::FatalError(char const*, char const*) [/app/.heroku/node/bin/node]
2021-06-12T08:20:28.958737+00:00 app[web.1]:  3:  v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/app/.heroku/node/bin/node]
2021-06-12T08:20:28.959345+00:00 app[web.1]:  4: v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/app/.heroku/node/bin/node]*

尝试在项目设置下的 Config Vars 中添加 NODE_OPTIONS 作为键和 --max_old_space_size=1024

NODE_OPTIONS --max_old_space_size=1024 value.

我在 https://bismobaruno.medium.com/fixing-memory-heap-reactjs-on-heroku-16910e33e342

中找到了这个