When dealing with a HapiJS server w/ multiple connections, there are no friendly safeguards to prevent plugins from decorating the request object multiple times. For example:
exports.register = (server, options, next) => {
server.decorate('request', 'decoratedFunctionName', .... );
}
As stated in HapiJS's documentation:
Note that decorations apply to the entire server and all its connections regardless of current selection.
Since we are registering the plugin across multiple connections, the only way to get the above to work is using a try/catch block. It'd be super useful if there was a mechanism to help check for an existing decoration. Perhaps something as simple as a method that'd return an array of existing decorations on the request object, like so:
server.inspect('request')
and return:
['decoratedFunctionName', ...]
Related issues:
outmoded/discuss#415
hapijs/cookie#119
When dealing with a HapiJS server w/ multiple connections, there are no friendly safeguards to prevent plugins from decorating the request object multiple times. For example:
As stated in HapiJS's documentation:
Since we are registering the plugin across multiple connections, the only way to get the above to work is using a try/catch block. It'd be super useful if there was a mechanism to help check for an existing decoration. Perhaps something as simple as a method that'd return an array of existing decorations on the request object, like so:
server.inspect('request')and return:
['decoratedFunctionName', ...]Related issues:
outmoded/discuss#415
hapijs/cookie#119