Skip to content

Nuxt listen hook is returning wrong server from 3.7.0 #205

Description

@TechAkayy

Environment

  • Operating System: Darwin
  • Node Version: v18.12.1
  • Nuxt Version: 3.7.0
  • CLI Version: 3.7.3
  • Nitro Version: 2.6.2
  • Package Manager: npm@8.19.2
  • Builder: -
  • User Config: modules, devtools
  • Runtime Modules: ()
  • Build Modules: -

Reproduction

Worked before in 3.6.5 - https://github.com/TechAkayy/nuxt-365
Stopped working in 3.7.0 - https://github.com/TechAkayy/nuxt-370

Clone & install deps in both repo. Start dev-server. Check console in the editor - nuxt-365 logsDevserver running at: 3000, but nuxt-370 logs Devserver running at: 60225 (port numbers might be different)

Describe the bug

I'm a module author, and I use the nuxt listen hook to know which port is the devserver running.

The above reproduction is minimal and only difference is the nuxt version used (3.6.5 vs 3.7.0)

Nuxt listen hook returned correct port number in 3.6.5, but doesn't from 3.7.0 - https://nuxt.com/docs/api/advanced/hooks#nuxt-hooks-build-time

Please refer to the inline module in nuxt.config.ts, and this is the way I use the hook:

      nuxt.hook('listen', async (listenerServer) => {
        // @ts-ignore
        const port = listenerServer.address().port
        console.log(`Devserver running at: ${port}`)
      })

Additional context

Thanks for looking into this. If you require any more info, please let m eknow.

Logs

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions