phaserjs / phaser-editor-issues

Phaser Editor's bug tracker.
0 stars 0 forks source link

Doesn't check taken port #19

Open photonstorm opened 1 month ago

photonstorm commented 1 month ago

The templates don't check if the port is already in use when you Run them from Phaser Editor.

This may need fixing on a template level, or within the editor? @gammafp can help decide.

gammafp commented 1 month ago

It is a topic that needs to be discussed, the Vite family templates choose the next available port. The templates cannot edit the PhaserEditor configuration file to change the port dynamically.

PhaserEditor2D commented 1 month ago

You should configure the port in the development server configuration and in the phaser editor configuration. The editor will always open the browser in the port set in phasereditor2d.config.json. Scanning for a new port is not a solution. It should be a fixed port. I think if the port is used by another server not related to the game, then there is little to do -I think.

PhaserEditor2D commented 1 month ago

A sofisticated solution may be to let the editor to scan a free port and start the development server in that port. But it will require to set to the editor a "template command" to start the local server. Something like:

{
   "port": 0,
   "script": "npm run dev --port {port}"
}

Yet I don't know if we really need it.

photonstorm commented 1 month ago

Longer term, we should bundle a dev server with the Editor, so there's no need to download one at all. Then, we can control the ports much more easily. It will still have to scan for a free port, no app these days can assume a port to be available.

For this issue though we need to think of another solution. Currently, changing the port is too time consuming and complicated. There must be an easier way for the dev server / templates to communicate the chosen port to the editor - even if it's as simple as writing it to a file in the project folder.