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

File descriptor issues with Mocha in ElementaryOS #27

Open
josiah14 opened this issue Mar 3, 2015 · 4 comments
Open

File descriptor issues with Mocha in ElementaryOS #27

josiah14 opened this issue Mar 3, 2015 · 4 comments

Comments

@josiah14
Copy link

josiah14 commented Mar 3, 2015

It seems mock-fs can't create the mock filesystem correctly in ElementaryOS??? This code works fine on OSX.

Mocha and Chai.expect are being used, here.

The test:

  /*
   * ::getFtpFileList
   */
  describe('::getFtpFileList', function () {
    var mockfs = require('mock-fs'),
        fs = require('fs');

    describe('When the directory contains only files', function () {
      before(function () {
        mockfs({
            'test': {
              'file.txt': 'contents',
              'file1.ext': ''
            }
        });
      });

      after(function () {
        mockfs.restore();
      });

      it('Injects a String Array of all the files with their full paths', function () {
        functions.getFtpFileList('test', function (err, files) {
          expect(files).to.deep.equal([
            'test/file.txt',
            'test/file1.ext'
          ]);

          expect(err).to.equal(null);
        });
      });
    });

The error

 6 passing (86ms)
  1 failing

  1) For module functions ::getFtpFileList When the directory contains only files "before all" hook:
     Uncaught Error: EBADF, bad file descriptor
    at Binding._getDescriptorById (/project_dir/node_modules/mock-fs/lib/binding.js:189:11)
    at Binding.<anonymous> (/project_dir/node_modules/mock-fs/lib/binding.js:375:27)
    at maybeCallback (/project_dir/node_modules/mock-fs/lib/binding.js:27:18)
    at Binding.writeBuffer (/project_dir/node_modules/mock-fs/lib/binding.js:374:10)
    at Object.fs.write (/project_dir/node_modules/mock-fs/node/fs-0.10.28.js:513:11)
    at WriteStream._write (/project_dir/node_modules/mock-fs/node/fs-0.10.28.js:1677:6)
    at doWrite (_stream_writable.js:226:10)
    at clearBuffer (_stream_writable.js:305:5)
    at onwrite (_stream_writable.js:263:7)
    at WritableState.onwrite (_stream_writable.js:97:5)
    at /project_dir/node_modules/mock-fs/node/fs-0.10.28.js:1683:5
    at Object.wrapper [as oncomplete] (/project_dir/node_modules/mock-fs/node/fs-0.10.28.js:510:5)
@Slayer95
Copy link

I am seeing this error at fs.write in one setup of Windows 7.
Also a similar EBADF error in a Windows 8 setup, though from fs.close.

@MiniXC
Copy link

MiniXC commented May 23, 2016

Also having this problem when using fs.readFileSync on Linux.

     Error: EBADF, bad file descriptor
      at Binding.<anonymous> (node_modules/mock-fs/lib/binding.js:343:13)
      at maybeCallback (node_modules/mock-fs/lib/binding.js:41:17)
      at Binding.read (node_modules/mock-fs/lib/binding.js:335:10)
      at Object.fs.readSync (node_modules/mock-fs/node/fs-6.0.0.js:651:19)
      at Object.fs.readFileSync (node_modules/mock-fs/node/fs-6.0.0.js:472:24)

@mrchief
Copy link

mrchief commented Oct 28, 2016

On Windows 7, I'm getting EBADF too. Just calling mock() throws this error. Also, mock({'path/to/dir': {}}) throws same error.

@cco3
Copy link

cco3 commented Dec 29, 2018

What node versions are you all running? I get this on 10, but not on 8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants