I am running mocha/chai (3.2.0/3.5.0) based test cases for my nodejs (6.10.2) based application, on macOS 10.12.4, and I am running into a "Segmentation fault: 11" failure.
So far I have tried:
- Erasing my node_modules folder and doing a new
npm install
- Checking for outdated dependencies and upgrading them
- Upgrading the nodejs version (was using 6.7.0), via
sudo port upgrade nodejs6
The code that is failing for me is as follows.
chai.request(url)
.post(`/api/filestore?token=${token}`)
.timeout(20000)
.attach('file', fs.readFileSync(filepath), filename)
.field('name', data.name)
.field('description', data.description)
.field('keywords', data.keywords)
.end(function(err, res) {
if (err) { done(err); }
res.should.have.status(200);
res.should.be.json;
res.body.should.have.property('name');
res.body.should.have.property('description');
res.body.should.have.property('categories');
res.body.keywords.should.be.a('array');
res.body.keywords.join(',').should.be.equal(data.keywords);
done();
});
The segmentation fault disappears when I remove the 'attach' line:
.attach('file', fs.readFileSync(filepath), filename)
I have tried the fs.readFileSync(filepath)
separately and I don't encounter the issue.
This wasn't an issue in the past and only became an issue recently. I am wondering whether it coincides with the upgrade of the OS, but I can't be sure.
Does anyone have any suggestions?
via Andre M
No comments:
Post a Comment