Skip to content

Global Routes pre option error #2438

@timcosta

Description

@timcosta

When defining my server config as

serverConfig = 
    app: 
        Information: Information
    cache: [
        {
            name: "sessionCache"
            engine: require('catbox-redis')
            host: redisUrl.hostname
            password: redisUrl.auth.split(":")[1] if redisUrl.auth?
            partition: "session"
        }
    ]
    connections:
        load:
            maxEventLoopDelay: 3000
        routes:
            pre: [
                {
                    method:'getAuthUser(auth)'
                    assign:"user"
                }
            ]
    load:
        sampleInterval: 5000

I receive a converting circular structure error as follows

[ERROR] 21:00:16 TypeError
TypeError: Converting circular structure to JSON
  at Object.stringify (native)
  at Error.internals.annotate (/Users/timcosta/chalkup/dev/node_modules/hapi/node_modules/joi/lib/errors.js:137:26)
  at Object.exports.assert (/Users/timcosta/chalkup/dev/node_modules/hapi/lib/schema.js:15:125)
  at new module.exports.internals.Server (/Users/timcosta/chalkup/dev/node_modules/hapi/lib/server.js:32:22)
  at Object.<anonymous> (/Users/timcosta/chalkup/dev/web.coffee:64:14)
  at Object.<anonymous> (/Users/timcosta/chalkup/dev/web.coffee:2:1)
  at Module._compile (module.js:456:26)
  at Object.loadFile (/Users/timcosta/chalkup/dev/node_modules/coffee-script/lib/coffee-script/register.js:16:19)
  at Object..coffee (/usr/local/lib/node_modules/node-dev/lib/hook.js:52:17)
  at Module.load (/Users/timcosta/chalkup/dev/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
  at Function.Module._load (module.js:312:12)
  at Module.require (module.js:364:17)
  at require (module.js:380:17)
  at Object.<anonymous> (/Users/timcosta/chalkup/dev/web-test.js:2:18)
  at Module._compile (module.js:456:26)
  at Object.Module._extensions..js (module.js:474:10)
  at Object..js (/usr/local/lib/node_modules/node-dev/lib/hook.js:52:17)
  at Module.load (module.js:356:32)
  at Function.Module._load (module.js:312:12)
  at Module.require (module.js:364:17)
  at require (module.js:380:17)
  at Object.<anonymous> (/usr/local/lib/node_modules/node-dev/lib/wrap.js:51:1)
  at Module._compile (module.js:456:26)
  at Object.Module._extensions..js (module.js:474:10)
  at Module.load (module.js:356:32)
  at Function.Module._load (module.js:312:12)
  at Function.Module.runMain (module.js:497:10)
  at startup (node.js:119:16)
  at node.js:929:3

The error goes away as soon as I remove the pre line from routes. Is this a bug in Hapi? I'm trying to assign my user object to the request object for every request without needing to use pre in every route definition, and this is the best way I have found so far but it doesn't seem to work.

Metadata

Metadata

Assignees

Labels

bugBug or defect

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions