0

在我部署了我的 Angular 7 应用程序并尝试在浏览器上打开它后,我收到错误 500。检查日志我发现:

A  FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory 
A   1: node::Abort() [node] 
A   2: 0x74f83c6b2ae [node] 
A   3: v8::Utils::ReportOOMFailure(char const*, bool) [node] 
A   4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [node] 
A   5: v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [node] 
A   6: v8::internal::String::SlowFlatten(v8::internal::Handle<v8::internal::ConsString>, v8::internal::PretenureFlag) [node] 
A   7: v8::internal::parsing::ParseProgram(v8::internal::ParseInfo*, v8::internal::Isolate*) [node] 
A   8: 0x74f8416f63b [node] 
A   9: v8::internal::Compiler::GetSharedFunctionInfoForScript(v8::internal::Handle<v8::internal::String>, v8::internal::Handle<v8::internal::Object>, int, int, v8::ScriptOriginOptions, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Context>, v8::Extension*, v8::internal::ScriptData**, v8::ScriptCompiler::CompileOptions, v8::internal::NativesFlag) [node] 
A  10: v8::ScriptCompiler::CompileUnboundInternal(v8::Isolate*, v8::ScriptCompiler::Source*, v8::ScriptCompiler::CompileOptions) [node] 
A  11: 0x74f83c9a9fb [node] 
A  12: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [node] 
A  13: v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) [node] 
A  14: 0x2ef87fd042fd 
A  Aborted 

问题是,如果你用谷歌搜索FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory,修复应该将 package.json 起始行更改为 this "start": "node --max_old_space_size=4096 dist/server",。这样,日志中的错误就消失了,但页面仍然给出错误 500,现在日志仅显示以下内容:

F  GET 500 0 B 3.3 s Chrome 70 / GET 500 0 B 3.3 s Chrome 70 5cb9a64b00ff0dd3429e5e7b0e0001657e6e6f6c696665000166726f6e74656e643a323031393034313974313333353337000100
A  Node Express server listening on http://localhost:8080 

也许我需要在 app.yaml 文件中写入更多内容或更改它,现在它看起来像这样:

runtime: nodejs8
env: standard
service: frontend

我的 Angular 应用程序也是服务器端渲染的,不使用 firebase。

4

1 回答 1

0

我让它工作了。问题似乎在 app.yaml 文件中。我不得不将 instance_class 设置为 F2。如果你没有设置你是默认的 F1 并且那个类的内存太低了。现在我的 app.yaml 文件如下所示:

runtime: nodejs8
env: standard
service: frontend
instance_class: F2
于 2019-04-19T11:20:35.383 回答