在我部署了我的 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起始行更改为此"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
我的角度应用也是服务器端渲染的,不使用Firebase。
我让它工作了。问题似乎出在 app.yaml 文件中。我不得不将instance_class设置为 F2。如果未设置,则为默认 F1,并且该类中的内存太低。现在我的app.yaml文件看起来像这样:
runtime: nodejs8
env: standard
service: frontend
instance_class: F2