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

🐛 Bug: mocha fails with spawn EINVAL on windows with node 22 #5162

Open
3 of 4 tasks
maxonfjvipon opened this issue Jun 27, 2024 · 2 comments
Open
3 of 4 tasks

🐛 Bug: mocha fails with spawn EINVAL on windows with node 22 #5162

maxonfjvipon opened this issue Jun 27, 2024 · 2 comments
Labels
status: waiting for author waiting on response from OP - more information needed type: bug a defect, confirmed by a maintainer

Comments

@maxonfjvipon
Copy link

maxonfjvipon commented Jun 27, 2024

Bug Report Checklist

  • I have read and agree to Mocha's Code of Conduct and Contributing Guidelines
  • I have searched for related issues and issues with the faq label, but none matched my issue.
  • I have 'smoke tested' the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, my usage of Mocha, or Mocha itself.
  • I want to provide a PR to resolve this

Expected

Tests with mochajs successfully start to execute without errors on GHA CI on windows

Actual

CI fails with:

Running "mochacli:test" (mochacli) task
Warning: spawn EINVAL  Use --force to continue.

Aborted due to warnings.

Tests are not even started to execute.

Example of failed pipeline: https://github.com/objectionary/eo2js/actions/runs/9693490408/job/26749043096

Minimal, Reproducible Example

I run just regular js tests via GHA on windows using Gruntfile.js:

module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    clean: ['temp'],
    mochacli: {
      test: {
        options: {
          timeout: '1200000',
          files: ['test/**/*.test.js', '!test/resources/**'],
        },
      },
    }
  })
  grunt.loadNpmTasks('grunt-mocha-cli')
  grunt.registerTask('default', ['mochacli'])
}

regular.test.js:

const assert = require('assert')

it('', function() {
  assert.ok(true)
})

Versions

  • Tests run via GHA
  • OS: windows-latest
  • node_modules/.bin/mocha --version: 10.5.2
  • node --version: 22

Full CI script is here

Additional Info

My little research tells me that issue is related to April node security release and can be resolved by passing { shell: true } option to spawn function. But here there's no such option. I think the problem may be here

@maxonfjvipon maxonfjvipon added status: in triage a maintainer should (re-)triage (review) this issue type: bug a defect, confirmed by a maintainer labels Jun 27, 2024
@voxpelli
Copy link
Member

voxpelli commented Aug 5, 2024

Our windows tests passes? See eg. #5185. Are you sure this issue is with mocha and not with grunt? Since its grunt that's invoked initially:

cd eo2js-runtime && grunt

@voxpelli
Copy link
Member

voxpelli commented Aug 5, 2024

And the code path that calls

const proc = spawn(process.execPath, args, {
is triggered in the tests eg here, so if mocha is failing it should show in these tests I think
const err = await runMochaAsync(fixture, ['--unhandled-rejections=warn'], {

Maybe its this spawn that you are hitting instead? https://github.com/Rowno/grunt-mocha-cli/blob/be6eeb40cac537b8b016c6693956574ab153a59c/lib/index.js#L127

@voxpelli voxpelli added status: waiting for author waiting on response from OP - more information needed and removed status: in triage a maintainer should (re-)triage (review) this issue labels Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting for author waiting on response from OP - more information needed type: bug a defect, confirmed by a maintainer
Projects
None yet
Development

No branches or pull requests

2 participants