首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在构建一个angular电子应用程序时,"API致命错误处理程序在后台线程上处理内存不足后返回“

在构建一个angular电子应用程序时,"API致命错误处理程序在后台线程上处理内存不足后返回“
EN

Stack Overflow用户
提问于 2020-11-18 17:20:33
回答 1查看 245关注 0票数 0

我们使用角度10.2,电子4.2,电子生成器22.9和节点10.16.0。此外,我们还有一个jenkins管道,每次发出Pull请求时都要执行。此管道创建一个AWS windows实例(t2.large),以便下载代码并构建.exe文件。问题是在编译代码时,会弹出以下错误:Fatal error # API fatal error handler returned after process out of memory on the background thread.

节点变量--max_old_space_size value is 4191.868721008301 MB。如果手动启动AWS windows实例,运行npm install并手动构建代码,则不会触发任何错误,构建完全成功。该错误仅在jenkins启动AWS windows实例时发生。

在安装了--max_old_space_size=1.5GB的mac环境中,构建过程完全成功。同样,当使用--max_old_space_size=1.5GB在windows中手动测试时,构建也可以很好地完成。如果变量设置为--max_old_space_size=512MB,构建将失败,并显示另一个错误Javascript heap out of memory。

我猜是不是跟jenkins线程内存有关?但是我还没有找到增加线程内存的方法。

任何想法,小贴士都会很有帮助。

Jenkins文件:

代码语言:javascript
复制
stage ('Build Windows app') {
    node('windows-electron') {
        // Wipe the workspace so we are building completely clean
        deleteDir()

        checkout scm

        bat """
        cd app
        call npm run node-memory
        call node -v
        call npm --no-git-tag-version version \"${version}\"
        call npm install
        REM call npm run test - tests disabled on Windows for now (they run on Mac OS)
        call npm run build"""
    }
}

Package.json构建脚本:"build": "npm run download-translations && ng build --prod && electron-webpack && electron-builder --publish=never",

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-11-19 18:19:33

由于这个问题从angular 9 and 10 as well开始,我们创建了一个linux从站来执行构建过程,然后在mac和windows从站中隐藏文件和解锁。

代码语言:javascript
复制
node('nvm-slave') {
        // Wipe the workspace so we are building completely clean
        deleteDir()

        checkout scm

        nvm(nvmInstallURL: 'https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh', nvmIoJsOrgMirror: 'https://iojs.org/dist', nvmNodeJsOrgMirror: 'https://nodejs.org/dist', version: '10.16.0') {
            sh '''cd app
            npm install
            npx ng build --prod
            '''
        }

        stash name: "folder-to-stash", includes: "path/to/folder/to/stash/**"
}

stage ('Build Windows app') {
    node('windows-electron') {
        // Wipe the workspace so we are building completely clean
        deleteDir()

        checkout scm

        unstash "folder-to-stash"

        bat """
        cd app
        call node -v
        call npm --no-git-tag-version version \"${version}\"
        call npm install
        REM call npm run test - tests disabled on Windows for now (they run on Mac OS)
        call npm run postbuild"""

        archiveArtifacts 'app/dist/*.exe'
    }
}

Package.json脚本:

代码语言:javascript
复制
"build": "ng build --prod",
"postbuild": "electron-webpack && electron-builder --x64 --publish=never",
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64890177

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档