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

can't get exact listened port from configResolved or configureServer #5543

Closed
7 tasks done
HomyeeKing opened this issue Nov 4, 2021 · 3 comments
Closed
7 tasks done

Comments

@HomyeeKing
Copy link
Contributor

Describe the bug

for vite-plugin-inspect as example, we can't access the exact port from these two plugin hooks
image

Reproduction

image

System Info

System:
    OS: macOS 12.0.1
    CPU: (8) x64 Apple M1
    Memory: 20.14 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.17.3 - /usr/local/bin/node
    Yarn: 1.22.10 - ~/.npm-global/bin/yarn
    npm: 8.0.0 - ~/.npm-global/bin/npm
  Browsers:
    Chrome: 95.0.4638.69
    Safari: 15.1
  npmPackages:
    @vitejs/plugin-vue: ^1.9.4 => 1.9.4

Used Package Manager

pnpm

Logs

No response

Validations

@HomyeeKing HomyeeKing changed the title can't get exact listened port from resolvedConfig or configureServer can't get exact listened port from configResolved or configureServer Nov 4, 2021
@HomyeeKing
Copy link
Contributor Author

I've noticed there's a pr #4104 fix this, but it seems not the solution

@HomyeeKing
Copy link
Contributor Author

one solution is that the plugin author calling the listening event by hand
e.g.

configureServer(server){
    console.log(`configureServerSync`, server.config.server.port)
     
    server.httpServer?.once('listening',()=>{
   
        console.log('configureServer listening',server.config.server.port);
        
     })
}

image

@Shinigami92 Shinigami92 linked a pull request Nov 5, 2021 that will close this issue
9 tasks
@sapphi-red
Copy link
Member

Closing as it is impossible to implement it to those hooks and can be obtained after listening event.
#5542 (comment)

@github-actions github-actions bot locked and limited conversation to collaborators May 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants