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

not working on node 10.5 #238

Closed
twawszczak opened this issue Jun 21, 2018 · 7 comments
Closed

not working on node 10.5 #238

twawszczak opened this issue Jun 21, 2018 · 7 comments

Comments

@twawszczak
Copy link

after fs module refactors and changes

@demosdemon
Copy link

demosdemon commented Jun 29, 2018

ahh, this is my problem!

from node
https://github.com/nodejs/node/blob/ebf5b58bec6954ebeed1c302cf31ff55494a0c93/lib/fs.js#L238-L252

from mock-fs

mock-fs/lib/binding.js

Lines 357 to 380 in 5b165be

/**
* Stat an item.
* @param {number} fd File descriptor.
* @param {function(Error, Stats)|Float64Array} callback Callback (optional). In Node 7.7.0+ this will be a Float64Array
* that should be filled with stat values.
* @return {Stats|undefined} Stats or undefined (if sync).
*/
Binding.prototype.fstat = function(fd, callback) {
return maybeCallback(wrapStatsCallback(callback), this, function() {
var descriptor = this._getDescriptorById(fd);
var item = descriptor.getItem();
var stats = item.getStats();
// In Node 7.7.0+, binding.stat accepts a Float64Array as the second argument,
// which should be filled with stat values.
// In prior versions of Node, binding.stat simply returns a Stats instance.
if (callback instanceof Float64Array) {
fillStatsArray(stats, callback);
} else {
fillStatsArray(stats, statValues);
return new Stats(stats);
}
});
};

@jimthedev
Copy link

If anyone has any good ideas on how to solve this I'd be willing to put in a PR.

@tomhughes
Copy link
Contributor

I've opened #240 which fixes the issues with stat/fstat/lstat but there is a second set of problems with createReadStream and createWriteStream which I have not been able to find a fix for so far.

Basically the problem is that after restoring the mocked fs and then starting a new one writing to a stream created against the new mock fs will wind up calling back into writeBuffers with an fd from the new context but with this bound to the old context which leads the fd not being found. I have so far been unable to determine exactly why however...

@tschaub
Copy link
Owner

tschaub commented Jul 23, 2018

Stat calls now work (thanks @tomhughes). I need to do more debugging to figure out how to handle the read after open.

@3cp
Copy link
Collaborator

3cp commented Sep 6, 2018

Any progress?

@mistic
Copy link

mistic commented Nov 7, 2018

@tschaub @tomhughes any news on solving the streams bug in Node v10.5+? This just become urgent for my current use case

jan-molak added a commit to serenity-js/serenity-js that referenced this issue Nov 11, 2018
affects: @serenity-js/core

The latest available version we can test on is 10.4 as mock-fs doesn't support node >= 10.5 yet
(tschaub/mock-fs#238)
jan-molak added a commit to serenity-js/serenity-js that referenced this issue Nov 11, 2018
affects: @serenity-js/core

The latest available version we can test on is 10.4 as mock-fs doesn't support node >= 10.5 yet
(tschaub/mock-fs#238)
@tschaub
Copy link
Owner

tschaub commented Feb 4, 2019

This should be addressed on the 4.8.0 release (thanks @huochunpeng, see #260).

@tschaub tschaub closed this as completed Feb 4, 2019
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

7 participants