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 'const interval = options.ops.interval;' #487

Closed
makusan opened this issue May 18, 2016 · 8 comments
Closed

Error 'const interval = options.ops.interval;' #487

makusan opened this issue May 18, 2016 · 8 comments
Assignees
Labels
bug
Milestone

Comments

@makusan
Copy link

@makusan makusan commented May 18, 2016

Hi,

I was just following the hapijs tutorial and i got this error after adding the logging part "good".
When trying to run the node server, the following errors occurred. What should i do?

$ node server
C:\Users\maku\Documents\NodeProjects\hapijs\myproject\node_modules\good\lib\index.js:21
            const interval = options.ops.interval;
                                        ^

TypeError: Cannot read property 'interval' of undefined
    at C:\Users\maku\Documents\NodeProjects\hapijs\myproject\node_modules\good\lib\index.js:21:41
    at Items.serial (C:\Users\maku\Documents\NodeProjects\hapijs\myproject\node_modules\hapi\lib\server.js:381:18)
    at iterate (C:\Users\maku\Documents\NodeProjects\hapijs\myproject\node_modules\hapi\node_modules\items\lib\index.js:36:13)
    at Object.exports.serial (C:\Users\maku\Documents\NodeProjects\hapijs\myproject\node_modules\hapi\node_modules\items\lib\index.js:39:9)
    at internals.Server._invoke (C:\Users\maku\Documents\NodeProjects\hapijs\myproject\node_modules\hapi\lib\server.js:378:11)
    at Items.parallel (C:\Users\maku\Documents\NodeProjects\hapijs\myproject\node_modules\hapi\lib\server.js:260:14)
    at done (C:\Users\maku\Documents\NodeProjects\hapijs\myproject\node_modules\hapi\node_modules\items\lib\index.js:63:25)
    at process.nextTick (C:\Users\maku\Documents\NodeProjects\hapijs\myproject\node_modules\hapi\node_modules\catbox-memory\node_modules\hoek\lib\index.js:850:22)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

maku@FALCON MINGW64 ~/Documents/NodeProjects/hapijs/myproject
$ node -v
v6.2.0
@arb

This comment has been minimized.

Copy link
Contributor

@arb arb commented May 18, 2016

What version of good? Can I see your config setup?

@arb arb self-assigned this May 18, 2016
@makusan

This comment has been minimized.

Copy link
Author

@makusan makusan commented May 18, 2016

Hi, here's my config, i'm running nodejs on Windows 10 x64

maku@FALCON MINGW64 ~/Documents/NodeProjects/hapijs/myproject
$ node -v && npm -v
v6.2.0
3.9.0

// Exactly the same from tutorial
// server.js

'use strict';

const Hapi = require('hapi');
const Good = require('good');

const server = new Hapi.Server();
server.connection({ port: 3000 });

server.route({
    method: 'GET',
    path: '/',
    handler: function (request, reply) {
        reply('Hello, world!');
    }
});

server.route({
    method: 'GET',
    path: '/{name}',
    handler: function (request, reply) {
        reply('Hello, ' + encodeURIComponent(request.params.name) + '!');
    }
});

server.register({
    register: Good,
    options: {
        reporters: {
            console: [{
                module: 'good-squeeze',
                name: 'Squeeze',
                args: [{
                    response: '*',
                    log: '*'
                }]
            }, {
                module: 'good-console'
            }, 'stdout']
        }
    }
}, (err) => {

    if (err) {
        throw err; // something bad happened loading the plugin
    }

    server.start((err) => {

        if (err) {
           throw err;
        }
        server.log('info', 'Server running at: ' + server.info.uri);
    });
});


// package.json : 
{
  "name": "myproject",
  "version": "0.0.1",
  "description": "HapiJS Web App Tutorial",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/makusan/hapijs-tutorial/tutorial.git"
  },
  "author": "Makusan <makufx@gmail.com>",
  "license": "MIT",
  "dependencies": {
    "good": "^7.0.0",
    "good-console": "^6.1.1",
    "good-squeeze": "^3.0.1",
    "hapi": "^13.4.0",
    "inert": "^4.0.0"
  }
}
@arb

This comment has been minimized.

Copy link
Contributor

@arb arb commented May 18, 2016

Try adding and empty ops object to your options into good. I think we have a bug here, but I'm trying to just get this working for you right now.

@makusan

This comment has been minimized.

Copy link
Author

@makusan makusan commented May 18, 2016

How should i put that? Sorry, kinda new into this.

Thanks for your reply.

@arb

This comment has been minimized.

Copy link
Contributor

@arb arb commented May 18, 2016

    options: {
        reporters: {
            console: [{
                module: 'good-squeeze',
                name: 'Squeeze',
                args: [{
                    response: '*',
                    log: '*'
                }]
            }, {
                module: 'good-console'
            }, 'stdout']
        },
       ops: {}
    }
@akshayp

This comment has been minimized.

Copy link

@akshayp akshayp commented May 19, 2016

Looks like these options throw an error for interval being set to an invalid value (Running good@7.0.0 and good-console@6.1.1)

Error: interval must be less than 2147483648

const opts = options: {
    ops: {},
    reporters: {
        console: [{
            module: 'good-console',
            args: [{ log: ['error', 'medium'], response: '*' }]
        }, 'stdout']
    }
}
@arb arb added the bug label May 19, 2016
@arb arb modified the milestone: 7.0.1 May 19, 2016
@sjmcdowall

This comment has been minimized.

Copy link

@sjmcdowall sjmcdowall commented May 19, 2016

Here is a working example of the Good setup for the tutorial - not the ops -> interval .. this runs fine for me.
server.register({ register: Good, options: { ops: { interval: 1000 }, reporters: { console: [{ module: 'good-squeeze', name: 'Squeeze', args: [{ response: '*', log: '*' }] }, { module: 'good-console' }, 'stdout'] } }

arb added a commit to arb/good that referenced this issue May 19, 2016
arb added a commit to arb/good that referenced this issue May 19, 2016
@arb arb closed this in af29b1f May 19, 2016
@arb

This comment has been minimized.

Copy link
Contributor

@arb arb commented May 20, 2016

The interval object isn't required. There are defaults and you should only set it if you need something other than the defaults. This bug was fixed in version 7.0.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.