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

Nuxt hook "listen" is not firing #149

Closed
richardeschloss opened this issue Dec 21, 2021 · 7 comments
Closed

Nuxt hook "listen" is not firing #149

richardeschloss opened this issue Dec 21, 2021 · 7 comments
Labels

Comments

@richardeschloss
Copy link

richardeschloss commented Dec 21, 2021

Environment

Node LTS (16) on Linux / nuxt-bridge / nuxt-edge / vite

Reproduction

The nuxt "listen" hook does not seem to be firing. Please add it back in if it was deleted.

import { defineNuxtModule } from '@nuxt/kit'
export default defineNuxtModule({
  hooks: {
    listen( ) {
      // Never called
    }
  }
})

Describe the bug

The nuxt "listen" hook does not seem to be firing. Please add it back in if it was deleted.

Additional context

No response

Logs

No response

@richardeschloss
Copy link
Author

@danielroe danielroe added the nitro label Jan 4, 2022
@danielroe
Copy link
Member

danielroe commented Jan 7, 2022

(Related: nuxt/nuxt#11786). Because Nuxt is build-time only, there is nothing to call these server hooks. Instead we will implement via the ability to extend Nitro itself. I'm going to close this issue - but do follow the RFC at https://github.com/nuxt/framework/discussions/1690.

@pi0 pi0 reopened this Jan 7, 2022
@pi0
Copy link
Member

pi0 commented Jan 7, 2022

Indeed nuxt is build-time only and listener server is initiated before nuxt via nuxi cli. Still would be nice if we can fake hook for backward compatibility or possible edge case uses.

@pi0 pi0 added enhancement New feature or request nuxt3 and removed pending triage labels Jan 7, 2022
@richardeschloss
Copy link
Author

Fwiw, some background on this issue: my use case was waiting for the listen hook to fire so that I could re-use nuxt's server instance. Specifically, for socket.io. This way socket.io and nuxt could share the same port without requiring additional configuration. However, for the time being, I decided to just keep the two separate (on separate ports).

The more I think about it, it may be better design for Nuxt to treat it's own server instance as private and to remove the listen hook from the type definitions so people don't attempt to use the hook. It's properties though, like current host and port, may still be useful for developers to access.

@hareku
Copy link

hareku commented Feb 10, 2022

@danielroe Is there any way to set keepaliveTimeout etc for Node.js server in nuxi preview?

@pi0 pi0 transferred this issue from nuxt/framework Apr 13, 2022
@dabrowiecki
Copy link

@richardeschloss I have a similar problem, I want to provided prometheus metrics from the application on a separate port. What is the event that you are listening to in order to open socket.io connection? Listen hook sounds like a good moment to open the second connection.

@richardeschloss
Copy link
Author

@richardeschloss I have a similar problem, I want to provided prometheus metrics from the application on a separate port. What is the event that you are listening to in order to open socket.io connection? Listen hook sounds like a good moment to open the second connection.

I'm listening for listen (all lowercase):
https://github.com/richardeschloss/nuxt-socket-io/blob/5c04b4215584d2af1a4bdf1b02e5c987a68e703a/lib/module.js#L206

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants