-
Notifications
You must be signed in to change notification settings - Fork 167
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
Reuse the existing tab in browser when Vaadin app is started in dev mode #18393
Comments
After some investigation a suitable and reliable enough approach was not found. Via the Open library it is not possible to detect if a certain tab/window is open, or reuse/refresh it. One idea was to use a marker file which would be written when the browser window is opened for the first time, and on subsequent server starts check if this file exists, and if so, prevent opening another window. Drawbacks here is that we can't really detect if the user has closed the window at some point. A related issue is that it's unclear when and based on what criteria the file should be removed. One potential option for detecting open tab is the development mode web socket connection. When the server is shut down, the client will keep trying to reconnect every 5000ms. So, when the server is restarted and we get one of these pings, we know that there is an open window for the application and it is enough to refresh that window, which could probably be done with a reload command as a reply to the first ping. Downside of the last idea is that we would need to have some delayed mechanism on the server side, which would wait for the possible ping, and if it does not arrive, then opens a new window. For the cases when the window is not there, this would of course postpone opening the window, making the application start appear slower. To mitigate this, we could consider making the development mode web socket connection reconnect interval shorter, e.g. 500ms or 1000ms. |
I have not come up with any better ideas on this either. The developer should be able to change the timeout. |
I agree, that's pretty much the only reliable thing that can be done here. |
As we can not know if a tab for the application is open we add a file that is checked for modification time and after default 30 min we open a new tab on server restart. If server is restarted again before timeout file timestamp is updated. Clearing build folder will also cause new tab to open on next restart. Closes #18393
* feat: Open tab in dev mode less often As we can not know if a tab for the application is open we add a file that is checked for modification time and after default 30 min we open a new tab on server restart. If server is restarted again before timeout file timestamp is updated. Clearing build folder will also cause new tab to open on next restart. Closes #18393 * Unify duplicate code * Add configuration property and update parameter to launch-browser-delay
* chore: document launch-browser-delay property Refs vaadin/flow#18393 * Initial edits -- just the new text. * Edited whole document touched. * Third round of editing whole document touched. --------- Co-authored-by: Russell JT Dyer <russelljtdyer@users.noreply.github.com> Co-authored-by: Russell J.T. Dyer <6652767+russelljtdyer@users.noreply.github.com>
Describe your motivation
When Vaadin application is started in dev mode, it always opens a new tab in browser.
This quickly leads to many tabs opened in browser, which is annoying.
Would be good, if Vaadin reused the existing tab in the browser, if it exists.
Additional context
See BrowserLauncher (Flow repo) and Open library (Separate Vaadin repo).
The text was updated successfully, but these errors were encountered: