Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion failed : (0) at the end of karma execution #3511

Closed
matthintosh opened this issue May 15, 2020 · 8 comments
Closed

Assertion failed : (0) at the end of karma execution #3511

matthintosh opened this issue May 15, 2020 · 8 comments

Comments

@matthintosh
Copy link

matthintosh commented May 15, 2020

Issue

Hello, I using Karma + Webpack for running my unit tests and karma always display an error after testing and just before closing Chrome (or ChromeHeadless).

Error

The error is :
Assertion failed: (0), function uv_close, file ../deps/uv/src/unix/core.c, line 187.
[1] 18461 abort npm run test-debug

Below a copy of my terminal
TOTAL: 87 SUCCESS 15 05 2020 15:35:04.564:DEBUG [karma-server]: Run complete, exiting. 15 05 2020 15:35:04.564:DEBUG [launcher]: Disconnecting all browsers 15 05 2020 15:35:04.564:DEBUG [launcher]: BEING_FORCE_KILLED -> BEING_FORCE_KILLED Assertion failed: (0), function uv_close, file ../deps/uv/src/unix/core.c, line 187. [1] 18552 abort npm run test-debug

Software and hardware

The issue still appear on :

  • local environment (mac os Catalina 10.15.4) running the npm script
  • local environment running the maven script (java project+react) to build the entire project. Maven will failed because of the issue
  • gitlab CI running the maven script (linux server)

Karma config

Below my karma config :
`module.exports = function (config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '../../../',

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['requirejs', 'jasmine'],

    // list of files / patterns to load in the browser
    files: [
        //Static resources
        tests + 'test-main.js', // Will load ebxUI bundles..

        //Unit test here
        {pattern: tests + 'src/**/*.tsx', included: false},
        {pattern: tests + 'src/**/*.ts', included: false},

        //EBX lib
        {pattern: ebxUI + "js/**/*", included: false},

        {pattern: libTest + "/**/*", included: false}

    ],

    // list of files to exclude
    exclude: [],

    // // Redirect access to resources
    // proxies: {
    //   '/images/': 'http://localhost:11180/ebx-ui/images/'
    // },

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
        //TODO coverage is not useful currently, try to do like : https://github.com/mcliment/typescript-karma-webpack-coverage-sample
        'project-folder/src/test/src/react/**/*.ts*': ['webpack'],
    },

    webpack: webpackConfig,

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['progress', 'coverage'],

    // optionally, configure the reporter
    coverageReporter: {
        type: 'html',
        dir: tests + 'coverage/'
    },

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: false,

    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome',"ChromeCustom"],

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,

    // Concurrency level
    // how many browser should be started simultaneous
    concurrency: "Infinity",

    // Prevent karma to crash for empty
    // tests
    failOnEmptyTestSuite: false,

    // Set karma timeout
    browserNoActivityTimeout : 60000,
    processKillTimeout:30000,



    // Custom karma execution for CI
    customLaunchers: {
        ChromeCustom: {
            base: 'ChromeHeadless',
            // We must disable the Chrome sandbox when running Chrome inside Docker (Chrome's sandbox needs
            // more permissions than Docker allows by default)
            flags: isDocker ? ['--no-sandbox'] : []
        }
    }
})`

package.json file

image

More info

Sometimes (it's rare) the script end well and I don't have the issue.

NPM and node version

node: v12.16.3
npm:6.14.4

@devoto13
Copy link
Collaborator

It is not coming from Karma package, but rather from libuv (the binary used by Node itself). Can you try on the Node 12.15.0 (as libuv was updated in 12.16.0) and also on latest Node?

From the code it looks like Node attempts to close some resource of an unknown type and hence this assertion. This sounds either like Karma is doing something utterly wrong (not sure how it is possible though) or there is a bug in Node itself.

If you can provide a minimal Karma project which reliably produces this error this should help with debugging and potentially reporting a problem upstream.

@devoto13
Copy link
Collaborator

devoto13 commented May 15, 2020

Looks like the culprit is webpack/webpack#10037.

tl;dr Webpack is stuck with the older versions of fsevents/chokidar and maintainers of fsevents are unwilling to invest a lot of time into back-porting the fixes from the latest version (fsevents/fsevents#314). So either accept this issue or stay on older versions of Node where it is not present.

Karma has already upgraded to the latest fsevents and chokidar, so there is nothing for Karma core to fix here.

@matthintosh
Copy link
Author

Thank you for your reply, I will test it and let you know (maybe test with a beta version of webpack5 or some resolutions to force latest version of chokidar/fsevents).

@devoto13
Copy link
Collaborator

Actually this also may be caused by Karma. fsevents/fsevents#314 (comment) mentions that watcher should be closed asynchronously, which is not the case for Karma code. I'll create a branch with the change and ask you to test it just in case.

devoto13 added a commit to devoto13/karma that referenced this issue May 15, 2020
@devoto13
Copy link
Collaborator

Not sure if this will do any good for your particular case, but can you try this fix on your codebase?

Replace "karma": "5.0.5" in your package.json with "karma": "devoto13/karma#chokidar-await" and run npm i. This should install karma from the branch on GitHub.

@matthintosh
Copy link
Author

I just test with your fix and I still have the same issue.
Assertion failed: (0), function uv_close, file ../deps/uv/src/unix/core.c, line 187.
Thank you for your help.

@devoto13
Copy link
Collaborator

Okay, then the problem is likely coming from karma-webpack - webpack chain, so not much we can do about it.

@matthintosh
Copy link
Author

The last version of karma and karm-webpack resolve this issue ! Thank you.

devoto13 added a commit to devoto13/karma that referenced this issue Jan 18, 2021
kubkon pushed a commit to kubkon/fluentui that referenced this issue Jan 18, 2021
The fix turns out to be bumping `webpack` from `4.43` to `4.44` in
`packages/web-components`. Prior to this, I'd experience sporadic
errors when running `yarn test` like the ones documented in this
`karma` issue: [karma-runner/karma#3511](karma-runner/karma#3511).
It turns out, that the problem is not with `karma` but rather with
`webpack` as documented in [webpack/webpack#10037](webpack/webpack#10037).
As per the closing comment in that issue, ensure we use `watchpack`
version `^1.7.2` (a transitive dep of `webpack`) is enough to ensure
this sporadic error goes away, and to bump `watchpack` we need to
bump `webpack` by one minor version.
kubkon pushed a commit to kubkon/fluentui that referenced this issue Jan 18, 2021
The fix turns out to be bumping `webpack` from `4.43` to `4.44` in
`packages/web-components`. Prior to this, I'd experience sporadic
errors when running `yarn test` like the ones documented in this
`karma` issue: [karma-runner/karma#3511](karma-runner/karma#3511).
It turns out, that the problem is not with `karma` but rather with
`webpack` as documented in [webpack/webpack#10037](webpack/webpack#10037).
As per the closing comment in that issue, ensure we use `watchpack`
version `^1.7.2` (a transitive dep of `webpack`) is enough to ensure
this sporadic error goes away, and to bump `watchpack` we need to
bump `webpack` by one minor version.
kubkon pushed a commit to kubkon/fluentui that referenced this issue Jan 19, 2021
The fix turns out to be bumping `webpack` from `4.43` to `4.44` in
`packages/web-components`. Prior to this, I'd experience sporadic
errors when running `yarn test` like the ones documented in this
`karma` issue: [karma-runner/karma#3511](karma-runner/karma#3511).
It turns out, that the problem is not with `karma` but rather with
`webpack` as documented in [webpack/webpack#10037](webpack/webpack#10037).
As per the closing comment in that issue, ensure we use `watchpack`
version `^1.7.2` (a transitive dep of `webpack`) is enough to ensure
this sporadic error goes away, and to bump `watchpack` we need to
bump `webpack` by one minor version.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants