Skip to content

Commit 3e0435d

Browse files
fix: execute PushRequestHandler before DevModeHandler (#14383) (#14395)
When an application with PUSH enabled tries to re-establish the push connection after a server restart, it may happen that the dev mode handler responds to the push request with HTML contents (dev-mode-not-ready.html). In this situation, an error is shown on the browser page, a manual page reload is required to make the application work again. This changes the request handlers order so that the PushRequestHandler is executed before DevModeHandler Co-authored-by: Marco Collovati <marco@vaadin.com>
1 parent 04f5d32 commit 3e0435d

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

‎flow-server/src/main/java/com/vaadin/flow/server/VaadinServletService.java‎

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,6 @@ protected List<RequestHandler> createRequestHandlers()
8585
throws ServiceException {
8686
List<RequestHandler> handlers = super.createRequestHandlers();
8787
handlers.add(0, new FaviconHandler());
88-
if (isAtmosphereAvailable()) {
89-
try {
90-
handlers.add(new PushRequestHandler(this));
91-
} catch (ServiceException e) {
92-
// Atmosphere init failed. Push won't work but we don't throw a
93-
// service exception as we don't want to prevent non-push
94-
// applications from working
95-
getLogger().warn(
96-
"Error initializing Atmosphere. Push will not work.",
97-
e);
98-
}
99-
}
10088

10189
if (getDeploymentConfiguration().enableDevServer()) {
10290
Optional<DevModeHandler> handlerManager = DevModeHandlerManager
@@ -111,6 +99,22 @@ protected List<RequestHandler> createRequestHandlers()
11199
}
112100
}
113101

102+
// PushRequestHandler should run before DevModeHandler to avoid
103+
// responding with html contents when dev mode server is not ready
104+
// (e.g. dev-mode-not-ready.html)
105+
if (isAtmosphereAvailable()) {
106+
try {
107+
handlers.add(new PushRequestHandler(this));
108+
} catch (ServiceException e) {
109+
// Atmosphere init failed. Push won't work but we don't throw a
110+
// service exception as we don't want to prevent non-push
111+
// applications from working
112+
getLogger().warn(
113+
"Error initializing Atmosphere. Push will not work.",
114+
e);
115+
}
116+
}
117+
114118
addBootstrapHandler(handlers);
115119
return handlers;
116120
}

0 commit comments

Comments
 (0)