gpt4 book ai didi

typescript - Heroku - fatal error : Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

转载 作者:行者123 更新时间:2023-12-04 13:36:04 25 4
gpt4 key购买 nike

尝试将我的应用程序部署到 Heroku(免费 Dyno)时,我不断收到错误 FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory .

我已经尝试设置 node --optimize_for_size --max_old_space_size=460 --gc_interval=100正如 Heroku 常见问题支持中所推荐的那样,但在这里似乎没有帮助。

我的应用程序在本地 Windows 机器上运行良好,但在 Heroku 上,无论我做什么都会弹出错误。

它不是在启动脚本的阶段崩溃,而是在 tsc 上崩溃。编译。

也许我一直在错误的地方或其他地方使用节点选项,但我想这种方法由于某种原因在我的情况下不起作用。

有没有人在 Heroku 上遇到过同样的问题,你是如何解决的?

日志记录

2020-05-25T10:10:48.311880+00:00 heroku[web.1]: Starting process with command `npm run heroku`
2020-05-25T10:10:52.925897+00:00 app[web.1]:
2020-05-25T10:10:52.925919+00:00 app[web.1]: > express-backend@1.0.0 heroku /app
2020-05-25T10:10:52.925937+00:00 app[web.1]: > node --optimize_for_size --max_old_space_size=460 --gc_interval=100&&npm-run-all clean compile copy start
2020-05-25T10:10:52.925938+00:00 app[web.1]:
2020-05-25T10:10:54.329357+00:00 app[web.1]:
2020-05-25T10:10:54.329371+00:00 app[web.1]: > express-backend@1.0.0 clean /app
2020-05-25T10:10:54.329372+00:00 app[web.1]: > rm -rf ./dist
2020-05-25T10:10:54.329372+00:00 app[web.1]:
2020-05-25T10:10:55.482684+00:00 app[web.1]:
2020-05-25T10:10:55.482694+00:00 app[web.1]: > express-backend@1.0.0 compile /app
2020-05-25T10:10:55.482695+00:00 app[web.1]: > tsc
2020-05-25T10:10:55.482695+00:00 app[web.1]:
2020-05-25T10:11:13.835222+00:00 app[web.1]:
2020-05-25T10:11:13.835249+00:00 app[web.1]: <--- Last few GCs --->
2020-05-25T10:11:13.835250+00:00 app[web.1]: lu[70:0x44b09a0] 17193 ms: Mark-sweep 255.8 (257.3) -> 255.0 (257.6) MB, 260.7 / 0.0 ms (+ 0.0 ms in 3 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 278 ms) (average mu = 0.123, current mu = 0.062) allocation failure[70:0x44b09a0] 17326 ms: Mark-sweep 256.1 (257.6) -> 255.8 (257.6) MB, 83.2 / 0.0 ms (+ 25.2 ms in 12 steps since start of marking, biggest step 3.2 ms, walltime since start of marking 133 ms) (average mu = 0.145, current mu = 0.185) allocation failur
2020-05-25T10:11:13.835251+00:00 app[web.1]:
2020-05-25T10:11:13.835251+00:00 app[web.1]: <--- JS stacktrace --->
2020-05-25T10:11:13.835251+00:00 app[web.1]:
2020-05-25T10:11:13.835252+00:00 app[web.1]: ==== JS stack trace =========================================
2020-05-25T10:11:13.835252+00:00 app[web.1]:
2020-05-25T10:11:13.835253+00:00 app[web.1]: 0: ExitFrame [pc: 0x13c5b79]
2020-05-25T10:11:13.835253+00:00 app[web.1]: Security context: 0x01b71b3008d1 <JSObject>
2020-05-25T10:11:13.835255+00:00 app[web.1]: 1: addJSDocComment(aka addJSDocComment) [0xd947801e629] [/app/node_modules/typescript/lib/tsc.js:~15330] [pc=0x11ea5812c367](this=0x39366b7804b1 <undefined>,0x0ad037f13561 <Node map = 0xfdad2eb2b19>)
2020-05-25T10:11:13.835256+00:00 app[web.1]: 2: parseTypeMember(aka parseTypeMember) [0xd9478020029] [/app/node_modules/typescript/lib/tsc.js:~16687] [pc=0x11ea5818c740](this=0x39366b7804b1 <undefined>)...
2020-05-25T10:11:13.835256+00:00 app[web.1]:
2020-05-25T10:11:13.835432+00:00 app[web.1]: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
2020-05-25T10:11:13.835433+00:00 app[web.1]:
2020-05-25T10:11:13.848262+00:00 app[web.1]: Writing Node.js report to file: report.20200525.101113.70.0.001.json
2020-05-25T10:11:13.848264+00:00 app[web.1]: Node.js report completed
2020-05-25T10:11:13.848539+00:00 app[web.1]: 1: 0xa09830 node::Abort() [node]
2020-05-25T10:11:13.848757+00:00 app[web.1]: 2: 0xa09c55 node::OnFatalError(char const*, char const*) [node]
2020-05-25T10:11:13.852130+00:00 app[web.1]: 3: 0xb7d71e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
2020-05-25T10:11:13.852131+00:00 app[web.1]: 4: 0xb7da99 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
2020-05-25T10:11:13.852132+00:00 app[web.1]: 5: 0xd2a1f5 [node]
2020-05-25T10:11:13.852132+00:00 app[web.1]: 6: 0xd2a886 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]
2020-05-25T10:11:13.852133+00:00 app[web.1]: 7: 0xd37105 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node]
2020-05-25T10:11:13.852542+00:00 app[web.1]: 8: 0xd37fb5 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
2020-05-25T10:11:13.856595+00:00 app[web.1]: 9: 0xd3aa6c v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
2020-05-25T10:11:13.856597+00:00 app[web.1]: 10: 0xd0163b v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]
2020-05-25T10:11:13.856598+00:00 app[web.1]: 11: 0x104300e v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]
2020-05-25T10:11:13.856599+00:00 app[web.1]: 12: 0x13c5b79 [node]
2020-05-25T10:11:13.883615+00:00 app[web.1]: Aborted
2020-05-25T10:11:13.887422+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-05-25T10:11:13.887588+00:00 app[web.1]: npm ERR! errno 134
2020-05-25T10:11:13.888930+00:00 app[web.1]: npm ERR! express-backend@1.0.0 compile: `tsc`
2020-05-25T10:11:13.889100+00:00 app[web.1]: npm ERR! Exit status 134
2020-05-25T10:11:13.889247+00:00 app[web.1]: npm ERR!
2020-05-25T10:11:13.889249+00:00 app[web.1]: npm ERR! Failed at the express-backend@1.0.0 compile script.
2020-05-25T10:11:13.889411+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-05-25T10:11:13.899422+00:00 app[web.1]:
2020-05-25T10:11:13.900471+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-05-25T10:11:13.901218+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-05-25T10_11_13_890Z-debug.log
2020-05-25T10:11:13.913416+00:00 app[web.1]: ERROR: "compile" exited with 134.
2020-05-25T10:11:13.919863+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-05-25T10:11:13.920329+00:00 app[web.1]: npm ERR! errno 1
2020-05-25T10:11:13.921443+00:00 app[web.1]: npm ERR! express-backend@1.0.0 heroku: `node --optimize_for_size --max_old_space_size=460 --gc_interval=100&&npm-run-all clean compile copy start`
2020-05-25T10:11:13.921603+00:00 app[web.1]: npm ERR! Exit status 1
2020-05-25T10:11:13.921779+00:00 app[web.1]: npm ERR!
2020-05-25T10:11:13.921933+00:00 app[web.1]: npm ERR! Failed at the express-backend@1.0.0 heroku script.
2020-05-25T10:11:13.922075+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-05-25T10:11:13.934678+00:00 app[web.1]:
2020-05-25T10:11:13.935097+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-05-25T10:11:13.935307+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-05-25T10_11_13_922Z-debug.log
2020-05-25T10:11:14.015702+00:00 heroku[web.1]: Process exited with status 1

包.json
{
"name": "express-backend",
"version": "1.0.0",
"description": "",
"main": "./dist/server.js",
"scripts": {
"prebuild": "npm-run-all -s clean",
"predev": "npm-run-all -s clean",
"clean": "rm -rf ./dist",
"start": "node --optimize_for_size --max_old_space_size=460 --gc_interval=100 ./dist/server.js",
"compile": "tsc",
"copy": "cpy src/graphql/schemas/*.graphql dist/graphql/schemas --no-overwrite",
"build": "tsc&&npm run copy",
"dev": "tsc-watch --onSuccess \"npm-run-all -s copy start\"",
"heroku": "node --optimize_for_size --max_old_space_size=460 --gc_interval=100&&npm-run-all clean compile copy start"
},
"config": {
"node-options": "--optimize_for_size --max_old_space_size=460 --gc_interval=100"
},
"engines": {
"node": "12.16.3",
"npm": "6.14.4"
},
"author": "",
"license": "ISC",
"dependencies": {
"@types/bcryptjs": "2.4.2",
"@types/compression": "1.7.0",
"@types/crypto-js": "3.1.44",
"@types/express": "4.17.3",
"@types/graphql": "14.5.0",
"@types/js-base64": "2.3.1",
"@types/jsonwebtoken": "8.3.9",
"@types/mongoose": "5.7.8",
"@types/validator": "13.0.0",
"apollo-server-express": "2.11.0",
"bcryptjs": "2.4.3",
"body-parser": "1.19.0",
"compression": "1.7.4",
"cors": "2.8.5",
"crypto-js": "4.0.0",
"dotenv": "8.2.0",
"express": "4.17.1",
"googleapis": "39.2.0",
"graphql": "14.6.0",
"graphql-middleware": "4.0.2",
"graphql-shield": "7.2.3",
"graphql-tools": "4.0.7",
"js-base64": "2.5.2",
"jsonwebtoken": "8.5.1",
"merge-graphql-schemas": "1.7.6",
"moment": "2.24.0",
"mongoose": "5.9.6",
"npm-run-all": "4.1.5",
"password-validator": "5.0.3",
"rimraf": "3.0.2",
"simple-crypto-js": "2.2.0",
"validator": "13.0.0",
"winston": "3.2.1",
"typescript": "3.8.3",
"cpy-cli": "^3.1.1"
},
"devDependencies": {
"tsc-watch": "^4.2.3"
}
}

配置文件
web: npm run heroku

最佳答案

我在部署 angular 应用程序时遇到了这个问题,我通过在 package.json 中添加 node 和 npm 版本来修复它。喜欢:"engines": {"node": "12.x","npm": "6.x" }

关于typescript - Heroku - fatal error : Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62000529/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com