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

Fastify 3.10 breaks prefixed plugins #97

Closed
Skn0tt opened this issue Jan 16, 2021 · 2 comments · Fixed by #98
Closed

Fastify 3.10 breaks prefixed plugins #97

Skn0tt opened this issue Jan 16, 2021 · 2 comments · Fixed by #98

Comments

@Skn0tt
Copy link

Skn0tt commented Jan 16, 2021

🐛 Bug Report

Fastify 3.10, together with the use of prefixes, breaks fastify-websocket.

fastify.register(
  (fastify, opts, done) => {
    fastify.get("/", { websocket: true }, (connection, req) => {
      connection.socket.send("This works");
    });

    done();
  },
  { prefix: "/activity" }
);

To Reproduce

Your Environment

  • node version: 15.3
  • fastify version: >=3.10
  • os: Mac

Some ideas as to what may be causing this

Prior to 3.10, this line was called twice per route:

fastify.addHook('onRoute', routeOptions => {

That's why this lines makes sure to ignore one of them:

if (routeOptions.path === routeOptions.prefix) {

Now with 3.10, the onRoute is called only once, and all of the routes are effectively ignored.

originally encountered in quirrel-dev/quirrel#49

@mcollina
Copy link
Member

I agree with your analysis! Would you like to send a PR to fix this module?

@mcollina
Copy link
Member

Please check out #98, it should fix the problem.

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

Successfully merging a pull request may close this issue.

2 participants