hapijs / good

hapi process monitoring
Other
525 stars 160 forks source link

Error "name" is required #578

Closed khmelevskii closed 6 years ago

khmelevskii commented 6 years ago
const good = {
    plugin: require('good'),
    options: {
        ops: {
            interval: 60000,
        },
        includes: {
            request: [
                'headers',
                'payload',
            ],
        },
        reporters: {
            accessReporter: [
                {
                    module: 'good-squeeze',
                    name: 'Squeeze',
                    args: [{ log: '*', response: '*' }],
                }, {
                    module: 'good-console'
                },
                'stdout'
            ],
        },
    },
};

Error:

Error: AssertionError [ERR_ASSERTION]: Invalid plugin options {
  "plugin": {
    "register": (server, options, next) => {\n\n    const result = Joi.validate(options, Schema.monitor);\n    Hoek.assert(!result.error, 'Invalid', 'monitorOptions', 'options', result.error);\n\n    const monitor = new Monitor(server, result.value);\n    server.ext([{\n        type: 'onPostStop',\n        method: internals.onPostStop(monitor)\n    }, {\n        type: 'onPreStart',\n        method: internals.onPreStart(monitor, result.value)\n    }]);\n\n    return monitor.start(next);\n},
    "name" [1]: -- missing --
  },
  "options": {
    "ops": {
      "name": "aaa",
      "config": {
        "name": "bbb"
      },
      "interval": 60000
    },
    "includes": {
      "request": [
        "headers",
        "payload"
      ]
    },
    "reporters": {
      "accessReporter": [
        {
          "module": "good-squeeze",
          "name": "Squeeze",
          "args": [
            {
              "log": "*",
              "response": "*"
            }
          ]
        },
        {
          "module": "good-console"
        },
        "stdout"
      ]
    }
  }
}

[1] "name" is required
Marsup commented 6 years ago

Likely a version mismatch but since you didn't provide any...

khmelevskii commented 6 years ago

sorry:

    "good": "^7.3.0",
    "good-squeeze": "^5.0.2",
    "hapi": "^17.2.0",
teddmason commented 6 years ago

@khmelevskii good v7 isn't compatible with hapi 17, you need to install the v8 release candidate "good": "8.0.0-rc1"

jeromecovington commented 6 years ago

I'm getting the "name" is required error running hapi 17 as well.

According to the hapi docs, of the possible exported values from a plugin: exports.plugin = { register, name, version, multiple, dependencies, once, pkg } The following values are required: register, name. See: https://github.com/hapijs/hapi/blob/master/API.md#plugins

However, of these required values, I only see register exported by good: https://github.com/hapijs/good/blob/master/lib/index.js#L27-L42

jeromecovington commented 6 years ago

^ This is for good@8.0.1 running hapi@17.2.0.

jeromecovington commented 6 years ago

Please ignore my last couple of comments on this issue. The "name" is required error I was seeing was coming from another, improperly register plugin, not good.

Kuchiriel commented 5 years ago

@jeromecovington May I know what plugin is it? I am having the same issue with hapi-auth-jwt2. I need desperately to solve this, it was months my app was down. I am in serious trouble...

Marsup commented 5 years ago

Make sure the plugins you use are compatible with your hapi version, it's not really about a specific plugin, could be any.

Kuchiriel commented 5 years ago

I've downgraded and tested the deps one by one and I've managed to make it work. I will comment here for anyone with the same issue after upgrading hapi.js and hapi.js plugins.

The problem seens to be, the newer versions of hapi.js and newers plugins don't work properly with es2018 code style.

Marsup commented 5 years ago

Joi can't be part of the issue, it has to be something registered with hapi. You can probably check quickly which it is by requiring all of them and checking the keys, anything out of the ordinary will likely be your culprit.

Kuchiriel commented 5 years ago

For me I supect the problem wast with hapi-auth-jwt2 and hapi-postgres-connection. As I said, I tested one by one, and after downgrading Hapi and those two plugins, it suddenly worked. I have no idea how, or why, and again I supect its something related to babel transpiling es2018 code, because I use preset-env and I write with the most recent features of ECMA.

lock[bot] commented 4 years ago

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.