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

multiple registrations not allowed #136

Open
fcesgpfedef opened this issue Mar 25, 2021 · 4 comments
Open

multiple registrations not allowed #136

fcesgpfedef opened this issue Mar 25, 2021 · 4 comments

Comments

@fcesgpfedef
Copy link

Hi,

We have written two custom plugins using hapi-pino for our project written on hapi20 and registered both the plugins with different options. When I am starting the server I am seeing the error hapi-pino is already registered. Any reason why hapi-pino is not supporting multiple registrations?

How can I resolve this issue in my project ? Any help is appreciated, Thanks.

@mcollina
Copy link
Collaborator

I don't know, I'm not using Hapi anymore :(. I'm not sure this is possible with Hapi.

@felixheck
Copy link
Collaborator

Hapi docs:
https://hapi.dev/api/?v=20.1.0#plugins

@osukaa
Copy link

osukaa commented Jun 7, 2021

You can force the multiple registrations by using once: true when calling server.register()

@thsmale
Copy link

thsmale commented Dec 13, 2022

Using once here won't do the job because if you are setting different options in the two hapi-pino registrations, hapi will only recognize one of those options and apply it to both.

As for why hapi-pino cannot support multiple registrations, the server.decorate('server', 'logger', logger) is to blame for this. The server decoration cannot be defined twice.

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

No branches or pull requests

5 participants