medikoo / memoizee

Complete memoize/cache solution for JavaScript
ISC License
1.73k stars 61 forks source link

Broken memoizee TEST npm test FAILED #63

Closed zeusintuivo closed 7 years ago

zeusintuivo commented 7 years ago

I am using this script to call the test. Inside a MAC

#!/bin/bash
#
# NVM
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm

nvm use v6.8.1

npm install
npm update
npm install
npm test

I get this error:

Now using node v6.8.1 (npm v3.10.8)

> memoizee@0.4.1 test /_/Sites/projects/api-endpoint/node_modules/memoizee
> node node_modules/tad/bin/tad

/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/_ext.js:75
            throw this.value;
            ^

TypeError: Cannot read property 'length' of undefined
    at Object.init (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/tad/index.js:37:26)
    at module.exports (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/tad/index.js:123:30)
    at /_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/tad/bin/tad:50:9
    at Function.then (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/_ext.js:60:18)
    at Object._settle (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/deferred.js:84:26)
    at Object.resolve (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/deferred.js:127:15)
    at Object.processValue (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/ext/array/map.js:78:49)
    at Function.done (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/_ext.js:77:12)
    at Object._settle (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/deferred.js:84:26)
    at Object.resolve (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/deferred.js:127:15)
    at Array.applyFn (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/ext/promise/invoke.js:26:9)
    at Function.<anonymous> (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/ext/promise/invoke.js:67:11)
    at Object._settle (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/deferred.js:84:26)
    at Object.resolve (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/deferred.js:127:15)
    at Function.<anonymous> (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/ext/promise/_array.js:30:3)
    at Object._settle (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/deferred.js:84:26)
    at Object.resolve (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/deferred.js:127:15)
    at /_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/fs2/readdir.js:460:26
    at Function.<anonymous> (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/ext/promise/aside.js:27:3)
    at Object._settle (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/deferred.js:84:26)
    at Object.resolve (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/deferred.js:127:15)
    at Function.then (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/_ext.js:64:4)
    at Object._settle (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/deferred.js:84:26)
    at Object.resolve (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/deferred.js:127:15)
    at Function.then (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/_ext.js:64:4)
    at Object._settle (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/deferred.js:84:26)
    at Object.resolve (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/deferred.js:127:15)
    at Object.processValue (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/ext/array/map.js:78:49)
    at Object.processCb (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/ext/array/map.js:72:8)
    at Function.done (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/_ext.js:77:12)
    at Object._settle (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/deferred.js:84:26)
    at Object.resolve (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/deferred.js:127:15)
    at Object.<anonymous> (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/fs2/lib/get-conf-file-map.js:83:11)
    at Function.done (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/_ext.js:77:12)
    at Object._settle (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/deferred.js:84:26)
    at Object.resolve (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/deferred.js:127:15)
    at Object.processValue (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/ext/array/map.js:78:49)
    at Function.done (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/_ext.js:77:12)
    at Object._settle (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/deferred.js:84:26)
    at Object.resolve (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/deferred.js:127:15)
    at Function.then (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/_ext.js:47:9)
    at Object._settle (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/deferred.js:84:26)
    at Object.resolve (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/deferred.js:127:15)
    at Function.then (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/_ext.js:64:4)
    at Object._settle (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/deferred.js:84:26)
    at Object.resolve (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/deferred/deferred.js:127:15)
    at resolve (/_/Sites/projects/api-endpoint/node_modules/memoizee/node_modules/fs2/read-file.js:27:7)
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:445:3)
npm ERR! Test failed.  See above for more details.
medikoo commented 7 years ago

@zeusintuivo

It looks that you're running tests on memoizee indirectly, via some additional suite, and that affects path data that tad receives.

It looks as tad doesn't receive the memoizee root path but something else, and crashes. The way it crashes is of course issue on tad size, and I'll look into that. There should be something more meaningful.

Anyway I'm pretty sure that everything will work as expected if in some bare path (not in context of any project) you'll do:

$ npm install memoizee
$ cd memoizee
$ npm install
$ npm test
medikoo commented 7 years ago

I've investigated it further, and error is caused by node_modules/tad/bin/tad (command that's configured for npm test script) being executed not in context of memoizee package folder.

It cannot work properly in such case, as it ended with search for modules to test not in memoizee but some other place.

In case you had there was no modules to test, and it crashed due to bug in tad, which you also reported and was fixed at https://github.com/medikoo/tad/pull/4

I don't think this is issue of memoizee therefore I'm closing it. Still if you have more details or ideas on that please elaborate

zeusintuivo commented 7 years ago

I will first follow the suggestion

$ npm install memoizee $ cd memoizee $ npm test

then try to see what it does.

On Wed, Oct 19, 2016 at 2:39 PM, Mariusz Nowak notifications@github.com wrote:

Closed #63 https://github.com/medikoo/memoizee/issues/63.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/medikoo/memoizee/issues/63#event-828984103, or mute the thread https://github.com/notifications/unsubscribe-auth/AIT-zbbxg1vKHzSQhdC3gFomY_GIX3oXks5q1g-agaJpZM4KavVx .

medikoo commented 7 years ago

@zeusintuivo just be sure install dev dependencies of the project. I've updated my instructions to include another npm install directly in memoizee folder

zeusintuivo commented 7 years ago

Perhaps you can also upgrade the version of TAD you are using, which is has another bug I remoted and now has been fixed."

QUOTING """"""

Mariusz Nowak notifications@github.com 2:36 PM (19 hours ago) to medikoo/tad, zeusintuivo, Author

Indeed there was an issue in handling scenarios when there are no files found for testing.

It's fixed with v0.2.7, thanks for reporting!

""""

On Wed, Oct 19, 2016 at 3:35 PM, Mariusz Nowak notifications@github.com wrote:

@zeusintuivo https://github.com/zeusintuivo just be sure install dev dependencies of the project. I've updated my instructions to include another npm install directly in memoizee folder

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/medikoo/memoizee/issues/63#issuecomment-254814117, or mute the thread https://github.com/notifications/unsubscribe-auth/AIT-zetfq5p62ApgX5jjvJb5ihPbdH5qks5q1hywgaJpZM4KavVx .

medikoo commented 7 years ago

@zeusintuivo fresh install of memoizee will for sure install the latest version of tad (no need for any change here), just be sure you removed node_modules and clear npm cache (all depends which npm version you're using)

zeusintuivo commented 7 years ago

I did and I still get version

 /_/tests/npm_memoizee_learn/node_modules/memoizee $  npm info | ü tad
tad: '^0.2.4',

On Thu, Oct 20, 2016 at 9:54 AM, Mariusz Nowak notifications@github.com wrote:

@zeusintuivo https://github.com/zeusintuivo fresh install of memoizee will for sure install the latest version of tad (no need for any change here), just be sure you removed node_modules and clear npm cache (all depends which npm version you're using)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/medikoo/memoizee/issues/63#issuecomment-255034683, or mute the thread https://github.com/notifications/unsubscribe-auth/AIT-zY8Z2qZppx9PZtq-nF0AwIK6cs10ks5q1x4dgaJpZM4KavVx .

medikoo commented 7 years ago

I'm not able to reproduce that, here's my output:

$ node -v
v4.6.1
$ npm -v
2.15.9
$ npm cache clean
$ mkdir test-memoizee
$ cd test-memoizee/
$ npm install memoizee
memoizee@0.4.1 node_modules/memoizee
├── is-promise@2.1.0
├── lru-queue@0.1.0
├── next-tick@1.0.0
├── d@1.0.0
├── timers-ext@0.1.0 (next-tick@0.2.2)
├── event-emitter@0.3.4 (d@0.1.1)
├── es6-weak-map@2.0.1 (d@0.1.1, es6-symbol@3.1.0, es6-iterator@2.0.0)
└── es5-ext@0.10.12 (es6-symbol@3.1.0, es6-iterator@2.0.0)
$ cd node_modules/memoizee/
$ npm install
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
plain-promise@0.1.1 node_modules/plain-promise

xlint-jslint-medikoo@0.1.4 node_modules/xlint-jslint-medikoo
└── xlint-jslint@0.1.0

tad@0.2.7 node_modules/tad
├── duration@0.2.0
├── d@0.1.1
├── optimist@0.6.1 (wordwrap@0.0.3, minimist@0.0.10)
├── path2@0.1.0
├── deferred@0.7.5 (next-tick@0.2.2)
├── test@0.6.0 (ansi-font@0.0.2)
├── next@0.4.1 (memoizee@0.3.10)
├── cli-color@1.1.0 (ansi-regex@2.0.0, es6-iterator@2.0.0, memoizee@0.3.10)
└── fs2@0.2.3 (memoizee@0.3.10, minimatch@2.0.10)

xlint@0.2.2 node_modules/xlint
├── d@0.1.1
├── cli-color@0.3.3
├── next@0.4.1
├── path2@0.1.0
├── deferred@0.7.5 (next-tick@0.2.2)
├── optimist@0.3.7 (wordwrap@0.0.3)
├── memoizee@0.3.10 (next-tick@0.2.2, es6-weak-map@0.1.4)
└── fs2@0.2.3 (minimatch@2.0.10)

As you see it installs tad@0.2.7. While I'm using here Node v4, I'm pretty sure same effect will be with v6

zeusintuivo commented 7 years ago

I installed nvm to manage several version of node

- REF: https://github.com/creationix/nvm
        : curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.4/
install.sh | bash

add to .bashrc, zshrc, .profile, bash_profile

# NVM
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm

I am using node 6.8.1, yesterday I updated to 6.9.0. and today 6.9.1 But for mean of this conversation, I keep the same version as when I reported it 6.8.1

I noticed you are using version v4.6.1..

About the version of TAD

I did wrote this

"""" Disregard last email

/_/projects/api-endpoint/node_modules/memoizee/node_modules/tad   master±
$  npm info | ü version
versions:
version: '0.2.7',

"""

Sorry about that,

On Thu, Oct 20, 2016 at 10:29 AM, Mariusz Nowak <notifications@github.com>
wrote:

> I'm not able to reproduce that, here's my output:
>
> $ node -v
> v4.6.1
> $ npm -v
> 2.15.9
> $ npm cache clean
> $ mkdir test-memoizee
> $ cd test-memoizee/
> $ npm install memoizee
> memoizee@0.4.1 node_modules/memoizee
> ├── is-promise@2.1.0
> ├── lru-queue@0.1.0
> ├── next-tick@1.0.0
> ├── d@1.0.0
> ├── timers-ext@0.1.0 (next-tick@0.2.2)
> ├── event-emitter@0.3.4 (d@0.1.1)
> ├── es6-weak-map@2.0.1 (d@0.1.1, es6-symbol@3.1.0, es6-iterator@2.0.0)
> └── es5-ext@0.10.12 (es6-symbol@3.1.0, es6-iterator@2.0.0)
> $ cd node_modules/memoizee/
> $ npm install
> npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
> plain-promise@0.1.1 node_modules/plain-promise
>
> xlint-jslint-medikoo@0.1.4 node_modules/xlint-jslint-medikoo
> └── xlint-jslint@0.1.0
>
> tad@0.2.7 node_modules/tad
> ├── duration@0.2.0
> ├── d@0.1.1
> ├── optimist@0.6.1 (wordwrap@0.0.3, minimist@0.0.10)
> ├── path2@0.1.0
> ├── deferred@0.7.5 (next-tick@0.2.2)
> ├── test@0.6.0 (ansi-font@0.0.2)
> ├── next@0.4.1 (memoizee@0.3.10)
> ├── cli-color@1.1.0 (ansi-regex@2.0.0, es6-iterator@2.0.0, memoizee@0.3.10)
> └── fs2@0.2.3 (memoizee@0.3.10, minimatch@2.0.10)
>
> xlint@0.2.2 node_modules/xlint
> ├── d@0.1.1
> ├── cli-color@0.3.3
> ├── next@0.4.1
> ├── path2@0.1.0
> ├── deferred@0.7.5 (next-tick@0.2.2)
> ├── optimist@0.3.7 (wordwrap@0.0.3)
> ├── memoizee@0.3.10 (next-tick@0.2.2, es6-weak-map@0.1.4)
> └── fs2@0.2.3 (minimatch@2.0.10)
>
> As you see it installs tad@0.2.7. While I'm using here Node v4, I'm
> pretty sure same effect will be with v6
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/medikoo/memoizee/issues/63#issuecomment-255042149>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AIT-zfmOEs31LTsnTBhk79oCoCE1Yj3Vks5q1yZNgaJpZM4KavVx>
> .
>
medikoo commented 7 years ago

With nvm if you follow the steps exactly the same way I show, you should have same effect.

Anyway now it's not clear what's the issue on your side. I believe we can agree that it's not tad version that installs with memoizee, as that can only be the issue of either npm cache or trying to reinstall over already installed (older) version of tad

zeusintuivo commented 7 years ago

Let talk about TAD now, tests are working and they are failing.

 node -v
v6.8.1
 npm -v
3.10.8

/_/tests/npm_memoizee_learn/node_modules/memoizee

/_/tests/npm_memoizee_learn/node_modules/memoizee/node_modules/tad $ npm
test

> tad@0.2.7 test
/_/tests/npm_memoizee_learn/node_modules/memoizee/node_modules/tad
> node ./bin/tad

10:51:42.093  ✓  lib/assert.js ......
10:51:42.111  ✓  lib/configure.js .............
10:51:42.118  ✓  lib/find-context.js ....
10:51:42.134  ✓  lib/find-test-path.js ..
10:51:42.136  -  lib/fix-test-utils.js
                 Tests could not be loaded, tried
'/_/tests/npm_memoizee_learn/node_modules/memoizee/node_modules/tad/test/lib/fix-test-utils.js'
10:51:42.138  ✓  lib/load.js ....
10:51:42.146  ✓  lib/logger.js ........
10:51:42.150  ✓  lib/run.js ......................
10:51:42.161  -  lib/tad-ignore-mode.js
                 Tests could not be loaded, tried
'/_/tests/npm_memoizee_learn/node_modules/memoizee/node_modules/tad/test/lib/tad-ignore-mode.js'
10:51:42.161  -  lib/utils/factory.js
                 Tests could not be loaded, tried
'/_/tests/npm_memoizee_learn/node_modules/memoizee/node_modules/tad/test/lib/utils/factory.js'
10:51:42.162  -  lib/utils/index-test.js
                 Tests could not be loaded, tried
'/_/tests/npm_memoizee_learn/node_modules/memoizee/node_modules/tad/test/lib/utils/index-test.js'

        .096     59 Ok [93.65%]  4 Errors

npm ERR! Test failed.  See above for more details.

On Thu, Oct 20, 2016 at 10:42 AM, Mariusz Nowak notifications@github.com wrote:

With nvm if you follow the steps exactly the same way I show, you should have same effect.

Anyway now it's not clear what's the issue on your side. I believe we can agree that it's not tad version that install with memoizee, as that can only be the issue of either npm cache or trying to reinstall over already installed (older) version of tad

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/medikoo/memoizee/issues/63#issuecomment-255045123, or mute the thread https://github.com/notifications/unsubscribe-auth/AIT-zXZ8DRA4erISpBaZUtiuk1r9-cs1ks5q1ylzgaJpZM4KavVx .

medikoo commented 7 years ago

Yes it's tests for tad, and they're not provided for some modules. It's known shortcoming still it shouldn't be an issue in usage of tad. Also it's not the case for memoizee (for that package all tests should load fine)

zeusintuivo commented 7 years ago

Yes, right now, I am happy with memoizee testing, even if its by itself. I will keep hacking into it .

On Thu, Oct 20, 2016 at 10:56 AM, Mariusz Nowak notifications@github.com wrote:

Yes it's tests for tad, and they're not provided for some modules. It's known shortcoming still it should be an issue in usage of tad. Also it's not the case for memoizee (in that projects all tests should load fine)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/medikoo/memoizee/issues/63#issuecomment-255048587, or mute the thread https://github.com/notifications/unsubscribe-auth/AIT-zcrxdGb78H2nt7kOqCamB9Khs-1nks5q1yzagaJpZM4KavVx .

zeusintuivo commented 7 years ago

Is there a way to know or log out, when cache was used and when cache was used not. We want to do this. Is it inside memoizee already, or do I have to do anyhting special for that?

On Thu, Oct 20, 2016 at 10:56 AM, Mariusz Nowak notifications@github.com wrote:

Yes it's tests for tad, and they're not provided for some modules. It's known shortcoming still it should be an issue in usage of tad. Also it's not the case for memoizee (in that projects all tests should load fine)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/medikoo/memoizee/issues/63#issuecomment-255048587, or mute the thread https://github.com/notifications/unsubscribe-auth/AIT-zcrxdGb78H2nt7kOqCamB9Khs-1nks5q1yzagaJpZM4KavVx .

medikoo commented 7 years ago

@zeusintuivo See profile functionality -> https://github.com/medikoo/memoizee/blob/master/README.md#profiling--statistics it should give you all you need.

If still you want to have events-like access to this data, then it's only possible via injecting custom extension,

zeusintuivo commented 7 years ago

I have this piece of code I am working on,

basically from proxy server.

the output of the app is stout and it gets captured by supervisord

It receives a request, authenticates places another request and prints the answer to the stdout,

I am very new to this nodejs, and for the life of me, I have no idea what this class does

I really would like to refactor it, given it is in EC6 already, right now it feel like horrible monster with all kinds bad practices from my point of view,

If you could give me a hand on this, I would really appreciate it, specially the part I working on

Which leads to the next question? What am I working on?

Well, I have to print stdout, "how long the request took" and "another json response" that show when the cache was used and when it was not.

On Wed, Oct 26, 2016 at 8:46 AM, Mariusz Nowak notifications@github.com wrote:

@zeusintuivo https://github.com/zeusintuivo See profile functionality -> https://github.com/medikoo/memoizee/blob/master/README. md#profiling--statistics it should give you all you need.

If still you want to have events-like access to this data, then it's only possible via injecting custom extension,

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/medikoo/memoizee/issues/63#issuecomment-256263005, or mute the thread https://github.com/notifications/unsubscribe-auth/AIT-zUUWakKConXnA8HypDlUGSicwpOVks5q3vcvgaJpZM4KavVx .