Coder Social home page Coder Social logo

Comments (9)

erikkemperman avatar erikkemperman commented on August 26, 2024

Traces are good. But it looks like it has to be done for every error instance, so in a lot of places. Would it make sense to try and bolt this onto graceful-fs, behind an option, since we are using that instead of vanilla fs pretty consistently across all modules?

from fs-mkdirp-stream.

phated avatar phated commented on August 26, 2024

Not sure that isaacs will accept something like that to graceful-fs but maybe we can try?

from fs-mkdirp-stream.

erikkemperman avatar erikkemperman commented on August 26, 2024

Oh! Didn’t know that was his. Yeah, no, I’m not holding my breath...

from fs-mkdirp-stream.

yocontra avatar yocontra commented on August 26, 2024

@phated graceful-fs is less of a hairball than node-glob so I would be in favor of forking it if the maintainers aren't being responsive.

We could merge any of these in that seem useful as well: https://github.com/isaacs/node-graceful-fs/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-desc and finally fix a bunch of our longstanding bugs with that project.

Eventually it might be a good idea to fork node-glob as well and finally have independence to solve our own problems 100%.

from fs-mkdirp-stream.

phated avatar phated commented on August 26, 2024

I've already had to take on a lot of dependencies to make sure everything was stable back to node 0.10 - I don't want to take on an FS module also 😞

from fs-mkdirp-stream.

phated avatar phated commented on August 26, 2024

There's a chance that graceful-fs is losing some error improvements from newer node versions. 😭

from fs-mkdirp-stream.

BridgeAR avatar BridgeAR commented on August 26, 2024

Heads up: In Node.js there is currently work in progress to improve that and in new versions the errors will also contain stack traces.

See nodejs/node#18106 as tracker.
Some errors are already getting improved right now: nodejs/node#17914 and nodejs/node#18348

from fs-mkdirp-stream.

coreyfarrell avatar coreyfarrell commented on August 26, 2024

I just ran a test for this, I created issue-3.js:

'use strict';

var fs = require('fs');
var path = require('path');

var outputDirpath = path.resolve('link');

try {
  fs.symlinkSync('not-exist', outputDirpath);
} catch (error) {
  // This shows an EEXIST stack trace on second run
  console.log(error);
}

fs.mkdir(outputDirpath, function(err) {
  // No stack trace here
  console.log(err);
});

fs.stat(outputDirpath, function(err) {
  // No stack trace here
  console.log(err);
});

The above script shows that the lack of stack trace is not caused by graceful-fs or fs-mkdirp-stream. Verified the issue on latest releases of node.js 4/6/8/10/12/14. Using graceful-fs instead of fs in the script yields the exact same results.

from fs-mkdirp-stream.

arogg avatar arogg commented on August 26, 2024

My solution gives very nice stacktraces.

Can someone tell me WHY this works? (because it does)
(fs is fs.promises for me BTW)

for(const name in fs){
    const func = fs[name];
    if (typeof func==='function'){
        fs[name]=async (...args)=>{
            const mystack = new Error().stack;
            try{
                return await func(...args);
            }catch(e){
                e.message+=mystack;
                throw e;
            }
        }
    }
}

from fs-mkdirp-stream.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.