Node.js Bash错误的退出代码

Node.js Bash错误的退出代码,node.js,bash,circleci,Node.js,Bash,Circleci,在CircleCI上,我正在配置文件中运行npm run test ci 我的package.json中有以下脚本: "test-ci": ". ./envvars/test.sh && nyc --all mocha --recursive --timeout 10000 && npm run report-coverage-ci", "report-coverage-ci": "nyc report --reporter=text-lcov > cove

在CircleCI上,我正在配置文件中运行
npm run test ci

我的package.json中有以下脚本:

"test-ci": ". ./envvars/test.sh && nyc --all mocha --recursive --timeout 10000 && npm run report-coverage-ci",
"report-coverage-ci": "nyc report --reporter=text-lcov > coverage.lcov && codecov -f coverage.json && echo CodeCov Done",
问题是,摩卡测试失败了,但它仍然在CircleCI上显示测试是成功的

因此,如果Mocha测试失败,它不应该继续到报告代码覆盖率的部分。但它仍在继续这一部分

你可以看到下面日志的最后一部分(我收回了一些敏感信息)

我怎样才能解决这个问题

    ✓ Should work with last key (3760ms)

<--- Last few GCs --->

[8488:0x3743ca0]   140011 ms: Scavenge 1328.2 (1422.9) -> 1327.9 (1423.9) MB, 7.2 / 0.0 ms  (average mu = 0.151, current mu = 0.118) allocation failure 
[8488:0x3743ca0]   140033 ms: Scavenge 1328.7 (1423.9) -> 1328.3 (1424.4) MB, 15.9 / 0.0 ms  (average mu = 0.151, current mu = 0.118) allocation failure 
[8488:0x3743ca0]   140056 ms: Scavenge 1329.1 (1424.4) -> 1328.8 (1425.4) MB, 7.7 / 0.0 ms  (average mu = 0.151, current mu = 0.118) allocation failure 


<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 0x1581d2a5c01d]
Security context: 0x18382199e549 <JSObject>
    1: /* anonymous */ [0x74025342ac9] [/home/circleci/repo/node_modules/q/q.js:~846] [pc=0x1581d355b56f](this=0x1ccc2a3a6ac9 <Object map = 0x3093e6868539>,fulfilled=0x1ccc2a3a67c1 <JSFunction query (sfi = 0x35b314d784e9)>,rejected=0x3344031826f1 <undefined>,progressed=0x3344031826f1 <undefined>)
    2: arguments adaptor frame: 1->3
    3: /* anonymous */ [0...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x8c02c0 node::Abort() [/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
 2: 0x8c030c  [/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
 3: 0xad15de v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
 4: 0xad1814 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
 5: 0xebe752  [/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
 6: 0xebe858 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
 7: 0xeca982 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
 8: 0xecb2b4 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
 9: 0xecdf21 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
10: 0xe97444 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
11: 0x1136d5e v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
12: 0x1581d2a5c01d 
-----------------------------------------|----------|----------|----------|----------|-------------------|
File                                     |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
-----------------------------------------|----------|----------|----------|----------|-------------------|
All files                                |        0 |        0 |        0 |        0 |                   |
 repo                                    |        0 |        0 |      100 |        0 |                   |
  create_tables.js                       |        0 |        0 |        0 |        0 |                   |
-----------------------------------------|----------|----------|----------|----------|-------------------|

> Project@1.0.0 report-coverage-ci /home/circleci/repo
> nyc report --reporter=text-lcov > coverage.lcov && codecov -f coverage.json && echo CodeCov Done

  _____          _  
 / ____|        | |  
| |     ___   __| | ___  ___ _____   __  
| |    / _ \ / _` |/ _ \/ __/ _ \ \ / /  
| |___| (_) | (_| |  __/ (_| (_) \ V /  
 \_____\___/ \__,_|\___|\___\___/ \_/  
                                v3.1.0
==> Detecting CI Provider
    Circle CI Detected
==> Configuration: 
    Endpoint: https://codecov.io
{ commit: '',
  branch: 'master',
  package: 'node-v3.1.0' }
==> Building file structure
==> Generating gcov reports (skip via --disable=gcov)
    $ find /home/circleci/repo -type f -name '*.gcno'  -exec gcov  {} +
==> Targeting specific file
    X Failed to read file at /home/circleci/repo/coverage.json
==> Uploading reports
    Success!
    View report at: https://codecov.io/github/rrainn/package/commit/
CodeCov Done
✓ 应使用最后一把钥匙(3760毫秒)
[8488:0x3743ca0]140011毫秒:清除1328.2(1422.9)->1327.9(1423.9)MB,7.2/0.0毫秒(平均mu=0.151,当前mu=0.118)分配失败
[8488:0x3743ca0]140033毫秒:清除1328.7(1423.9)->1328.3(1424.4)MB,15.9/0.0毫秒(平均mu=0.151,当前mu=0.118)分配失败
[8488:0x3743ca0]140056毫秒:清除1329.1(1424.4)->1328.8(1425.4)MB,7.7/0.0毫秒(平均mu=0.151,当前mu=0.118)分配失败
==JS堆栈跟踪=========================================
0:ExitFrame[pc:0x1581d2a5c01d]
安全上下文:0x18382199e549
1://*anonymous*/[0x74025342ac9][home/circleci/repo/node_modules/q/q.js:~846][pc=0x1581d355b56f](this=0x1CCC2A3A3A6C9,completed=0x1CCC2A3A3A67C1,rejected=0x3344001826F1,progressioned=0x3344001826F1)
2:参数适配器帧:1->3
3:/*匿名*/[0。。。
致命错误:无效的标记压缩接近堆限制分配失败-JavaScript堆内存不足
1:0x8c02c0节点::中止()[/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
2:0x8c030c[/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
3:0xad15de v8::Utils::ReportOOMFailure(v8::internal::Isolate*,char const*,bool)[/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
4:0xad1814 v8::internal::v8::FatalProcessOutOfMemory(v8::internal::Isolate*,char const*,bool)[/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
5:0xebe752[/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
6:0xebe858 v8::internal::Heap::CheckIneffectiveMarkCompact(无符号长,双精度)[/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
7:0xeca982 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector,v8::GCCallbackFlags)[/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
8:0xecb2b4 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace,v8::internal::GarbageCollectionReason,v8::GCCallbackFlags)[/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
9:0xecdf21 v8::internal::Heap::AllocateRawWithRetryOrFail(int,v8::internal::AllocationSpace,v8::internal::AllocationAlignment)[/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
10:0xe97444 v8::internal::Factory::NewFillerObject(int、bool、v8::internal::AllocationSpace)[/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
11:0x1136d5e v8::internal::Runtime_AllocateInNewSpace(int,v8::internal::Object**,v8::internal::Isolate*)[/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
12:0x1581d2a5c01d
-----------------------------------------|----------|----------|----------|----------|-------------------|
文件|%Stmts |%Branch |%Funcs |%Line |未覆盖行|s|
-----------------------------------------|----------|----------|----------|----------|-------------------|
所有文件| 0 | 0 | 0 | 0 ||
回购| 0 | 0 | 100 | 0 ||
创建_tables.js | 0 | 0 | 0 | 0 ||
-----------------------------------------|----------|----------|----------|----------|-------------------|
> Project@1.0.0报告覆盖范围ci/home/circleci/repo
>纽约报告--reporter=text lcov>coverage.lcov&&codecov-f coverage.json&&echo codecov完成
_____          _  
/ ____|        | |  
| |     ___   __| | ___  ___ _____   __  
| |    / _ \ / _` |/ _ \/ __/ _ \ \ / /  
|| | | | | | | | | | |/| | |(|)V/
\_____\___/ \__,_|\___|\___\___/ \_/  
v3.1.0
==>检测CI提供程序
检测到圆CI
==>配置:
终点:https://codecov.io
{提交:'',
分行:'主',
包:'node-v3.1.0'}
==>正在构建文件结构
==>生成gcov报告(通过--disable=gcov跳过)
$find/home/circleci/repo-type f-name'*.gcno'-exec gcov{}+
==>以特定文件为目标
X无法读取/home/circleci/repo/coverage.json中的文件
==>上传报告
成功!
查看报告的网址:https://codecov.io/github/rrainn/package/commit/
科德科夫完成

就bash而言,您的命令行是正确的。问题似乎是命令
nyc--all mocha--recursive--timeout 10000
失败了,但以零退出代码完成了执行。因此
&
操作符认为可以转到下一个命令

根本原因似乎是在mocha中,或者更具体地说是在node中。发布了一个github问题:


从问题评论来看,它似乎在node 8.10中得到了修复。

我正在运行node.js版本10.12,添加check coverage参数会改变什么吗?
nyc——所有mocha——递归——超时10000——检查覆盖率
。我不知道node.js、nyc或mocha中的任何一个,只是查看它们的代码并尝试以这种方式对其进行排序trict bash透视图-我的专业领域-一切都是正确的。你能想出解决方法吗?我们正在遇到它now@gnauhnoj我不这么认为。通常情况下,如果我解决了这个问题,我会发布我自己问题的答案。虽然这个问题已经问了很久了,所以我不是100%确定。我的CI基础结构已经发生了很大的变化自从有人问起这个问题以来,我就没遇到过这样的问题。