kevinbeaty / fs-promise

[DEPRECATED] Use mz or fs-extra^3 with Promise support
https://www.npmjs.com/package/fs-extra
MIT License
170 stars 13 forks source link

Errors are missing stack traces (Different from #19) #21

Closed ozum closed 7 years ago

ozum commented 7 years ago

Same question is asked in #19, but stack trace is missing even for non fs related errors when fs-promise is used in promise chain:

const fs = require('fs-promise');
let a;

fs.readdir('.')
  .then(files => a.invalid)
  .catch(console.log);

TypeError: Cannot read property 'invalid' of undefined at fs.readdir.then.files (/Users/ozum/Development/l10n-formatjs/sil.js:10:19)

On the other hand Bluebird or fs-extra-promise has stacks:

const Promise = require('bluebird')
const fs      = Promise.promisifyAll(require('fs-extra'));
// OR const fs   = require('fs-extra-promise');

let a;

fs.readdirAsync('.')
  .then(files => a.invalid)
  .catch(console.log);
TypeError: Cannot read property 'invalid' of undefined
    at fs.readdirAsync.then.files (/Users/ozum/Development/l10n-formatjs/sil.js:9:19)
    at tryCatcher (/Users/ozum/Development/l10n-formatjs/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/ozum/Development/l10n-formatjs/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/Users/ozum/Development/l10n-formatjs/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/Users/ozum/Development/l10n-formatjs/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/Users/ozum/Development/l10n-formatjs/node_modules/bluebird/js/release/promise.js:693:18)
    at Promise._fulfill (/Users/ozum/Development/l10n-formatjs/node_modules/bluebird/js/release/promise.js:638:18)
    at /Users/ozum/Development/l10n-formatjs/node_modules/bluebird/js/release/nodeback.js:42:21
    at go$readdir$cb (/Users/ozum/Development/l10n-formatjs/node_modules/fs-extra-promise/node_modules/graceful-fs/graceful-fs.js:149:14)
    at FSReqWrap.oncomplete (fs.js:114:15)
ozum commented 7 years ago

Problem seems to related to mz/fs. I would open a ticket there.

const fs   = require('mz/fs');

let a;

fs.readdir('.')
  .then(files => a.invalid)
  .catch(console.log);

TypeError: Cannot read property 'invalid' of undefined at fs.readdir.then.files (/Users/ozum/Development/l10n-formatjs/sil.js:9:19)