-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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
Added WebSocket arg to allow manually setting port #5963
Conversation
dynamic-entries websocket port
Could someone that ran into this explain exactly why this wouldn't work? We're using Node.js defaults by listening on port 0. So it seems like the correct default / the user shouldn't need to worry about this 🤔 |
Potentially because of a docker-compose type environment I guess? |
Yeah, I would think using a random port would work for most setups using Next. Although being able to manually map it could be good in case anyone keeps their environment's firewall locked down on a port basis or they are using a docker-compose environment as you said. @glenarama could you explain a little more your use case for manually mapping the WebSocket port? |
I'm using a Chromebook, it has a Linux container which I use for Dev. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should only be a next.config.js
option. I'm not sure about the name though 🤔 devWebsocketPort
🤔
The |
@ijjk could you add a section to the readme explaining that by default there is no need to configure this, but if you do you can do it by setting |
Could you also add a test for this if possible. There's a test suite for config options in |
and added test
I added a note in the README under "Configuring the onDemandEntries" let me know if that's not the right place for it. I also added a test in the suite you mentioned. I had to dynamically write to the |
packages/next/server/hot-reloader.js
Outdated
// create dynamic entries WebSocket | ||
this.wss = new WebSocket.Server({ port: 0 }, function (err) { | ||
this.wss = new WebSocket.Server({ port: devWebSocketPort || 0 }, function (err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's always read from devWebsocketPort
and add 0
as a default in packages/next-server/server/config.js` Then we have a single source of truth 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, I updated it
packages/next/README.md
Outdated
} | ||
}, | ||
// optionally configure a port for the onDemandEntries WebSocket, not needed by default | ||
devWebSocketPort: 3001, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized we have a onDemandEntries
key, totally forgot about it 🤦♂️ Can you move devWebSocketPort
under onDemandEntries
and call it websocketPort
🕵️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I'll merge 💯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per my updated comment, sorry for changing it yet again 😅
onDemandEntries config and added onDemandEntries to defaultConfig
It's all good, that seems like a better place for it. I also moved the |
Thanks guys, really appreciate it!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome thanks so much 🙏 Happy new year!
Happy New Year to you too! |
Saw a reply on the original pull request that the WebSocket using a random port broke their set up so I added a
--websocket
or-w
argument similar to the-p
argument to allow manually setting this port also.