chris-l / mock-couch

A node.js module designed to mock a CouchDB server, mostly for unit testing purposes.
http://chris-l.github.io/mock-couch/
67 stars 44 forks source link

crash on require('mock-couch') #55

Closed chriswatrous closed 6 years ago

chriswatrous commented 6 years ago

I'm having a problem with node crashing when I require mock-couch.

package.json

{
  "dependencies": {
    "mock-couch": "0.1.10"
  }
}

test.js

require('mock-couch');
bash> node test.js

#
# Fatal error in ../deps/v8/src/api.cc, line 1248
# Check failed: !value_obj->IsJSReceiver() || value_obj->IsTemplateInfo().
#
Illegal instruction: 4
bash> npm list
/Users/chris/projects/rmc/test
└─┬ mock-couch@0.1.10
  ├── color-convert@1.0.0 extraneous
  ├── couch-viewkey-compare@1.0.1
  ├── grunt@0.4.5 extraneous
  ├── grunt-jasmine-nodejs@1.5.2 extraneous
  ├── grunt-jslint@1.1.14 extraneous
  ├── ramda@0.8.0
  ├─┬ restify@2.8.5 invalid
  │ ├── assert-plus@0.1.5 extraneous
  │ ├── backoff@2.5.0 extraneous
  │ ├── bunyan@1.8.0 extraneous
  │ ├── csv@0.4.6 extraneous
  │ ├── deep-equal@0.2.2 extraneous
  │ ├── dtrace-provider@0.3.2 extraneous
  │ ├── escape-regexp-component@1.0.2 extraneous
  │ ├── formidable@1.0.17 extraneous
  │ ├── http-signature@0.10.1 extraneous
  │ ├── keep-alive-agent@0.0.1 extraneous
  │ ├── lru-cache@2.7.3 extraneous
  │ ├── mime@1.3.4 extraneous
  │ ├── negotiator@0.4.9 extraneous
  │ ├── node-uuid@1.4.7 extraneous
  │ ├── once@1.3.3 extraneous
  │ ├── qs@1.2.2 extraneous
  │ ├── semver@2.3.2 extraneous
  │ ├── spdy@1.32.5 extraneous
  │ ├── tunnel-agent@0.4.2 extraneous
  │ └── verror@1.6.1 extraneous
  └── underscore@1.8.3

npm ERR! extraneous: color-convert@1.0.0 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/color-convert
npm ERR! extraneous: grunt@0.4.5 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/grunt
npm ERR! extraneous: grunt-jasmine-nodejs@1.5.2 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/grunt-jasmine-nodejs
npm ERR! extraneous: grunt-jslint@1.1.14 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/grunt-jslint
npm ERR! invalid: restify@2.8.5 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/restify
npm ERR! extraneous: assert-plus@0.1.5 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/assert-plus
npm ERR! extraneous: backoff@2.5.0 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/backoff
npm ERR! extraneous: bunyan@1.8.0 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/bunyan
npm ERR! extraneous: csv@0.4.6 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/csv
npm ERR! extraneous: deep-equal@0.2.2 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/deep-equal
npm ERR! extraneous: dtrace-provider@0.3.2 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/dtrace-provider
npm ERR! extraneous: escape-regexp-component@1.0.2 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/escape-regexp-component
npm ERR! extraneous: formidable@1.0.17 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/formidable
npm ERR! extraneous: http-signature@0.10.1 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/http-signature
npm ERR! extraneous: keep-alive-agent@0.0.1 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/keep-alive-agent
npm ERR! extraneous: lru-cache@2.7.3 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/lru-cache
npm ERR! extraneous: mime@1.3.4 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/mime
npm ERR! extraneous: negotiator@0.4.9 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/negotiator
npm ERR! extraneous: node-uuid@1.4.7 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/node-uuid
npm ERR! extraneous: once@1.3.3 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/once
npm ERR! extraneous: qs@1.2.2 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/qs
npm ERR! extraneous: semver@2.3.2 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/semver
npm ERR! extraneous: spdy@1.32.5 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/spdy
npm ERR! extraneous: tunnel-agent@0.4.2 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/tunnel-agent
npm ERR! extraneous: verror@1.6.1 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/verror

I wonder if the problem is related to restify@2.8.5 invalid? I'm not sure what that means.

chriswatrous commented 6 years ago

I also tried with node v6.13.1 and it gave me a 493 line stack trace.

chriswatrous commented 6 years ago

Well this is wierd. If I delete node_modules but leave package-lock.json and reinstall, it works fine, and I get a very different output from npm list.

bash> npm list
/Users/chris/projects/rmc/test
└─┬ mock-couch@0.1.10
  ├── color-convert@1.0.0 extraneous
  ├── couch-viewkey-compare@1.0.1
  ├── grunt@0.4.5 extraneous
  ├── grunt-jasmine-nodejs@1.5.2 extraneous
  ├── grunt-jslint@1.1.14 extraneous
  ├── ramda@0.8.0
  ├─┬ restify@6.4.0
  │ ├── assert-plus@1.0.0
  │ ├─┬ bunyan@1.8.12
  │ │ ├── dtrace-provider@0.8.7 deduped
  │ │ ├── moment@2.22.2
  │ │ ├─┬ mv@2.1.1
  │ │ │ ├─┬ mkdirp@0.5.1
  │ │ │ │ └── minimist@0.0.8
  │ │ │ ├── ncp@2.0.0
  │ │ │ └─┬ rimraf@2.4.5
  │ │ │   └─┬ glob@6.0.4
  │ │ │     ├─┬ inflight@1.0.6
  │ │ │     │ ├── once@1.4.0 deduped
  │ │ │     │ └── wrappy@1.0.2 deduped
  │ │ │     ├── inherits@2.0.3 deduped
  │ │ │     ├─┬ minimatch@3.0.4
  │ │ │     │ └─┬ brace-expansion@1.1.11
  │ │ │     │   ├── balanced-match@1.0.0
  │ │ │     │   └── concat-map@0.0.1
  │ │ │     ├── once@1.4.0 deduped
  │ │ │     └── path-is-absolute@1.0.1
  │ │ └── safe-json-stringify@1.2.0
  │ ├─┬ clone-regexp@1.0.1
  │ │ ├── is-regexp@1.0.0
  │ │ └── is-supported-regexp-flag@1.0.1
  │ ├─┬ csv@1.2.1
  │ │ ├── csv-generate@1.1.2
  │ │ ├── csv-parse@1.3.3
  │ │ ├─┬ csv-stringify@1.1.2
  │ │ │ └── lodash.get@4.4.2
  │ │ └── stream-transform@0.2.2
  │ ├─┬ dtrace-provider@0.8.7
  │ │ └── nan@2.10.0
  │ ├── escape-regexp-component@1.0.2
  │ ├─┬ ewma@2.0.1
  │ │ └── assert-plus@1.0.0 deduped
  │ ├── formidable@1.2.1
  │ ├─┬ http-signature@1.2.0
  │ │ ├── assert-plus@1.0.0 deduped
  │ │ ├─┬ jsprim@1.4.1
  │ │ │ ├── assert-plus@1.0.0 deduped
  │ │ │ ├── extsprintf@1.3.0 deduped
  │ │ │ ├── json-schema@0.2.3
  │ │ │ └── verror@1.10.0 deduped
  │ │ └─┬ sshpk@1.14.2
  │ │   ├── asn1@0.2.3
  │ │   ├── assert-plus@1.0.0 deduped
  │ │   ├─┬ bcrypt-pbkdf@1.0.1
  │ │   │ └── tweetnacl@0.14.5 deduped
  │ │   ├─┬ dashdash@1.14.1
  │ │   │ └── assert-plus@1.0.0 deduped
  │ │   ├─┬ ecc-jsbn@0.1.1
  │ │   │ └── jsbn@0.1.1 deduped
  │ │   ├─┬ getpass@0.1.7
  │ │   │ └── assert-plus@1.0.0 deduped
  │ │   ├── jsbn@0.1.1
  │ │   ├── safer-buffer@2.1.2
  │ │   └── tweetnacl@0.14.5
  │ ├── lodash@4.17.10
  │ ├─┬ lru-cache@4.1.3
  │ │ ├── pseudomap@1.0.2
  │ │ └── yallist@2.1.2
  │ ├── mime@1.6.0
  │ ├── negotiator@0.6.1
  │ ├─┬ once@1.4.0
  │ │ └── wrappy@1.0.2
  │ ├── pidusage@1.2.0
  │ ├── qs@6.5.2
  │ ├─┬ restify-errors@5.0.0
  │ │ ├── assert-plus@1.0.0 deduped
  │ │ ├── lodash@4.17.10 deduped
  │ │ ├── safe-json-stringify@1.2.0 deduped
  │ │ └── verror@1.10.0 deduped
  │ ├── semver@5.5.0
  │ ├─┬ spdy@3.4.7
  │ │ ├─┬ debug@2.6.9
  │ │ │ └── ms@2.0.0
  │ │ ├── handle-thing@1.2.5
  │ │ ├── http-deceiver@1.2.7
  │ │ ├── safe-buffer@5.1.2
  │ │ ├── select-hose@2.0.0
  │ │ └─┬ spdy-transport@2.1.0
  │ │   ├── debug@2.6.9 deduped
  │ │   ├── detect-node@2.0.3
  │ │   ├─┬ hpack.js@2.1.6
  │ │   │ ├── inherits@2.0.3
  │ │   │ ├── obuf@1.1.2 deduped
  │ │   │ ├── readable-stream@2.3.6 deduped
  │ │   │ └── wbuf@1.7.3 deduped
  │ │   ├── obuf@1.1.2
  │ │   ├─┬ readable-stream@2.3.6
  │ │   │ ├── core-util-is@1.0.2 deduped
  │ │   │ ├── inherits@2.0.3 deduped
  │ │   │ ├── isarray@1.0.0
  │ │   │ ├── process-nextick-args@2.0.0
  │ │   │ ├── safe-buffer@5.1.2 deduped
  │ │   │ ├─┬ string_decoder@1.1.1
  │ │   │ │ └── safe-buffer@5.1.2 deduped
  │ │   │ └── util-deprecate@1.0.2
  │ │   ├── safe-buffer@5.1.2 deduped
  │ │   └─┬ wbuf@1.7.3
  │ │     └── minimalistic-assert@1.0.1
  │ ├── uuid@3.2.1
  │ ├─┬ vasync@1.6.4
  │ │ └─┬ verror@1.6.0
  │ │   └── extsprintf@1.2.0
  │ └─┬ verror@1.10.0
  │   ├── assert-plus@1.0.0 deduped
  │   ├── core-util-is@1.0.2
  │   └── extsprintf@1.3.0
  └── underscore@1.8.3

npm ERR! extraneous: color-convert@1.0.0 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/color-convert
npm ERR! extraneous: grunt@0.4.5 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/grunt
npm ERR! extraneous: grunt-jasmine-nodejs@1.5.2 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/grunt-jasmine-nodejs
npm ERR! extraneous: grunt-jslint@1.1.14 /Users/chris/projects/rmc/test/node_modules/mock-couch/node_modules/grunt-jslint
chriswatrous commented 6 years ago

If I delete node_modules and package-lock.json and reinstall, it fails again. Then if I just run npm install again it works.

chris-l commented 6 years ago

The purpose of package-lock.json is to specify exactly which version of each dependency it should install. If you delete node_modules but leave package-lock.json, it will reinstall each dependency, and it will make sure to install only the version that is specified there, which should guarantee that it will work.

If you delete package-lock.json (and you shouldn't do that) and then reinstall the dependencies, it will no longer check the version of each dependency, which could cause it to install broken dependencies.

According to your last comment, for some reason, if you delete both, reinstall, and then again execute npm install, it will install valid dependencies.

But as long reinstalling the dependencies with package-lock.json present works correctly, then it cannot be considered a problem of mock-couch.

I cannot replicate your problem; using the same node and npm versions as you (node v8.9.1 and npm v6.1.0), I executed the following commands:

mkdir test-mock
cd test-mock
npm init -y
npm install --save mock-couch
echo "require('mock-couch');">test.js
node test.js
# last command produces no output and returns without problems

Try to do that. If that works, then mock-couch is working correctly and for some reason you had broken dependencies installed on your project.

I must mention I did my tests using linux and not macos. Then again, I don't think that is related.