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

When vue.config.js set devServer.open to true it will open twice. #4063

Closed
lanseria opened this issue May 27, 2019 · 8 comments · Fixed by #4079
Closed

When vue.config.js set devServer.open to true it will open twice. #4063

lanseria opened this issue May 27, 2019 · 8 comments · Fixed by #4079

Comments

@lanseria
Copy link

lanseria commented May 27, 2019

Version

3.8.2

Environment info

Environment Info:

  System:
    OS: Windows 10
    CPU: (16) x64 AMD Ryzen 7 2700X Eight-Core Processor
  Binaries:
    Node: 10.15.3 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.16.0 - C:\Users\lanseria\AppData\Roaming\npm\yarn.CMD
    npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: 44.17763.1.0
  npmPackages:
    @vue/babel-helper-vue-jsx-merge-props:  1.0.0
    @vue/babel-plugin-transform-vue-jsx:  1.0.0
    @vue/babel-preset-app:  3.8.0
    @vue/babel-preset-jsx:  1.0.0
    @vue/babel-sugar-functional-vue:  1.0.0
    @vue/babel-sugar-inject-h:  1.0.0
    @vue/babel-sugar-v-model:  1.0.0
    @vue/babel-sugar-v-on:  1.0.0
    @vue/cli-overlay:  3.8.0
    @vue/cli-plugin-babel: ^3.8.0 => 3.8.0
    @vue/cli-plugin-eslint: ^3.8.0 => 3.8.0
    @vue/cli-service: ^3.8.0 => 3.8.0
    @vue/cli-shared-utils:  3.8.0
    @vue/component-compiler-utils:  2.6.0
    @vue/preload-webpack-plugin:  1.1.0
    @vue/web-component-wrapper:  1.2.0
    eslint-plugin-vue: ^5.0.0 => 5.2.2 (4.7.1)
    vue: ^2.6.10 => 2.6.10
    vue-eslint-parser:  5.0.0 (2.0.3)
    vue-hot-reload-api:  2.3.3
    vue-loader:  15.7.0
    vue-style-loader:  4.1.2
    vue-template-compiler: ^2.6.10 => 2.6.10
    vue-template-es2015-compiler:  1.9.1
  npmGlobalPackages:
    @vue/cli: Not Found

Steps to reproduce

vue create test
// create vue.config.js and sets devServer.host to ''0.0.0.0' and sets devServer.open: true, Then
yarn serve
// url: http://0.0.0.0:8080 quickly opened but unused
When compiled, url: http://localhost:8080/ opened

What is expected?

At least not pop up twice

What is actually happening?

Pop up twice, and the first time there is no response, the second IP address does not apply

@lanseria lanseria changed the title When vue.config.js sets devServer.host to ''0.0.0.0', it will open twice. When vue.config.js set devServer.host to '0.0.0.0', set devServer.open to true it will open twice. May 27, 2019
@trickstival
Copy link
Contributor

It's easy to reproduce.
I think the problem is somehow related to this line:

Since you want to open it in 0.0.0.0 should it be prettified? Removing this validation should close the issue

@trickstival
Copy link
Contributor

I checked that the open function:

open(url, options).catch(() => {}) // Prevent `unhandledRejection` error.
is just called once. Perhaps that's a problem with the 'open' package

@lanseria lanseria changed the title When vue.config.js set devServer.host to '0.0.0.0', set devServer.open to true it will open twice. When vue.config.js set devServer.open to true it will open twice. May 28, 2019
@xovel
Copy link
Contributor

xovel commented May 30, 2019

I'm confused about it too.

Is there any solution?

@trickstival
Copy link
Contributor

I don't see the reason for prettyfying the host address. If the user has set one, it should open a browser tab with exactly that.

But still, the real bug is in the "open" npm package, not in vue cli.

@xovel
Copy link
Contributor

xovel commented May 30, 2019

Finally, I figure it out. It seems ironicly.

@xovel
Copy link
Contributor

xovel commented May 30, 2019

The bug is not in open or opn package, but in webpack-dev-server. May it not a bug, just a strategy.

@trickstival
Copy link
Contributor

I was wrong. Is there any explanation for this behaviour?

@sodatea
Copy link
Member

sodatea commented May 30, 2019

Previously open option for webpack-dev-server only works with its own CLI. webpack/webpack-dev-server#1863 Now it also respects this flag passed via its Node API.

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.

4 participants