[go: nahoru, domu]

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

error: ./node_modules/.bin/rest-hapi-cli seed error #208

Closed
mescalito opened this issue Jan 13, 2020 · 4 comments · May be fixed by enterstudio/rest-hapi#37
Closed

error: ./node_modules/.bin/rest-hapi-cli seed error #208

mescalito opened this issue Jan 13, 2020 · 4 comments · May be fixed by enterstudio/rest-hapi#37

Comments

@mescalito
Copy link

Describe the bug
I'm following the quick-start guide:
https://resthapi.com/docs/quick-start.html

To Reproduce
Steps to reproduce the behavior:

  1. $ git clone https://github.com/JKHeadley/rest-hapi-demo.git
  2. $ cd rest-hapi-demo
  3. $ npm install
  4. $ ./node_modules/.bin/rest-hapi-cli seed

Step #4 is giving me some errors:

qqq@qqq-VirtualBox:~/code/rest-hapi-demo$ ./node_modules/.bin/rest-hapi-cli seed
[12:02:48.915] 11464 LOG      unseed — roles removed
[12:02:48.922] 11464 LOG      unseed — users removed
[12:02:48.922] 11464 LOG      seed — seeding roles
[12:02:48.940] 11464 LOG      seed — seeding users

(node:11464) UnhandledPromiseRejectionWarning: MongoError: TTL index 'expireAfterSeconds' option must be numeric, but received a type of 'null'. Index spec: { name: "date_1", key: { date: 1 }, expireAfterSeconds: null, background: true }
    at Function.MongoError.create (/home/qqq/code/rest-hapi-demo/node_modules/mongodb-core/lib/error.js:31:11)
    at /home/qqq/code/rest-hapi-demo/node_modules/mongodb-core/lib/connection/pool.js:497:72
    at authenticateStragglers (/home/qqq/code/rest-hapi-demo/node_modules/mongodb-core/lib/connection/pool.js:443:16)
    at Connection.messageHandler (/home/qqq/code/rest-hapi-demo/node_modules/mongodb-core/lib/connection/pool.js:477:5)
    at Socket.<anonymous> (/home/qqq/code/rest-hapi-demo/node_modules/mongodb-core/lib/connection/connection.js:333:22)
    at Socket.emit (events.js:210:5)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:290:11)
    at Socket.Readable.push (_stream_readable.js:224:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:182:23)
(node:11464) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:11464) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.


@JKHeadley
Copy link
Owner

@mescalito Thanks for reporting this. It looks like several people are experiencing similar issues. I'll try to look into this soon.

@kijamve
Copy link
kijamve commented Jan 19, 2020

@JKHeadley @mescalito Maybe it is a Mongoose bug or something that is not done well before this. But I fix it with this:

/node_modules/mongoose/lib/utils.js (find exports.expires line, aprox 570):

exports.expires = function expires(object) {
  if (!(object && object.constructor.name === 'Object')) {
    return;
  }
  if (!('expires' in object)) {
    return;
  }

  var when;
  if (typeof object.expires !== 'string') {
    when = object.expires;
  } else {
    when = Math.round(ms(object.expires) / 1000);
  }
  object.expireAfterSeconds = when;
  delete object.expires;
};

by this:

exports.expires = function expires(object) {
  if (!(object && object.constructor.name === 'Object')) {
    return;
  }
  if (!('expires' in object)) {
    return;
  }

  var when;
  if (object.expires == null) {
    when = 3600;
  } else if (typeof object.expires !== 'string') {
    when = object.expires;
  } else {
    when = Math.round(ms(object.expires) / 1000);
  }
  object.expireAfterSeconds = when;
  delete object.expires;
};

@JKHeadley
Copy link
Owner

fixed with #205

@mescalito this should be fixed now as long as you are using rest-hapi@v1.9.1 or higher

@kijamve nice find! However since manually editing files in node_modules is never idea for a permanent fix, you should be fine with the latest version of rest-hapi

@kijamve
Copy link
kijamve commented Jan 19, 2020

@JKHeadley Thanks, the change in node_module was while you search the real error xD

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

Successfully merging a pull request may close this issue.

3 participants