Skip to content

Commit cbbda72

Browse files
vaadin-botArtur-
andauthored
fix: Try polling again on connection refused (#16638) (#16762)
This should fix problems with the dev mode not ready page showing forever on startup Co-authored-by: Artur <artur@vaadin.com>
1 parent 41e526d commit cbbda72

1 file changed

Lines changed: 67 additions & 70 deletions

File tree

Lines changed: 67 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,75 @@
11
<html>
2-
<head>
3-
<meta name="viewport" content="width=device-width, initial-scale=1">
4-
<meta name="color-scheme" content="dark light">
5-
<style>
6-
body {
7-
display: flex;
8-
align-items: center;
9-
justify-content: center;
10-
margin: 0;
11-
padding: 1rem;
12-
min-height: 100vh;
13-
box-sizing: border-box;
14-
}
15-
16-
.message {
17-
background-color: rgba(50,50,50,1);
18-
color: white;
19-
border-radius: 2rem;
20-
box-sizing: border-box;
21-
padding: 0.75em 1.5em 0.75em 0.75em;
22-
font: 0.875rem/1.2 system-ui, ui-sans-serif, sans-serif;
23-
display: flex;
24-
align-items: center;
25-
gap: 0.75em;
26-
box-shadow: inset 0 0 0 1px rgba(255,255,255,.1), 0 3px 8px -3px rgba(0,0,0,0.6);
27-
}
28-
29-
/* Spinner */
30-
.message::before {
31-
content: '';
32-
flex: none;
33-
width: 1em;
34-
height: 1em;
35-
border-radius: 50%;
36-
border: 2px solid #2CA6FF;
37-
border-top-color: transparent;
38-
animation: spinner .5s linear infinite;
39-
-webkit-mask-image: radial-gradient(circle at 50% 2px, transparent 40%, #000 70%);
40-
mask-image: radial-gradient(circle at 50% 2px, transparent 40%, #000 70%);
41-
}
2+
<head>
3+
<meta name="viewport" content="width=device-width, initial-scale=1" />
4+
<meta name="color-scheme" content="dark light" />
5+
<style>
6+
body {
7+
display: flex;
8+
align-items: center;
9+
justify-content: center;
10+
margin: 0;
11+
padding: 1rem;
12+
min-height: 100vh;
13+
box-sizing: border-box;
14+
}
4215

43-
@keyframes spinner {
44-
to {transform: rotate(360deg);}
45-
}
46-
</style>
47-
<script type="text/javascript">
16+
.message {
17+
background-color: rgba(50, 50, 50, 1);
18+
color: white;
19+
border-radius: 2rem;
20+
box-sizing: border-box;
21+
padding: 0.75em 1.5em 0.75em 0.75em;
22+
font: 0.875rem/1.2 system-ui, ui-sans-serif, sans-serif;
23+
display: flex;
24+
align-items: center;
25+
gap: 0.75em;
26+
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), 0 3px 8px -3px rgba(0, 0, 0, 0.6);
27+
}
4828

49-
// Set specific flag for TB and make sure that there are no any clients.
50-
// It allows to work correct waitForVaadin in TB
51-
window.Vaadin = {Flow: {devServerIsNotLoaded: true}};
29+
/* Spinner */
30+
.message::before {
31+
content: '';
32+
flex: none;
33+
width: 1em;
34+
height: 1em;
35+
border-radius: 50%;
36+
border: 2px solid #2ca6ff;
37+
border-top-color: transparent;
38+
animation: spinner 0.5s linear infinite;
39+
-webkit-mask-image: radial-gradient(circle at 50% 2px, transparent 40%, #000 70%);
40+
mask-image: radial-gradient(circle at 50% 2px, transparent 40%, #000 70%);
41+
}
5242

53-
const delay = 200;
54-
const poll = () => {
55-
try {
56-
fetch(window.location.href, { headers: { 'X-DevModePoll': 'true' } }).then(response => {
57-
if (response.headers.has("X-DevModePending")) {
58-
setTimeout(poll, delay);
59-
} else {
60-
// App ready
61-
document.location.reload();
43+
@keyframes spinner {
44+
to {
45+
transform: rotate(360deg);
46+
}
6247
}
63-
})
64-
} catch (e) {
65-
setTimeout(poll, delay);
66-
}
67-
};
48+
</style>
49+
<script type="text/javascript">
50+
// Set specific flag for TB and make sure that there are no any clients.
51+
// It allows to work correct waitForVaadin in TB
52+
window.Vaadin = { Flow: { devServerIsNotLoaded: true } };
6853

69-
setTimeout(poll, delay);
54+
const delay = 200;
55+
const poll = async () => {
56+
try {
57+
const response = await fetch(window.location.href, { headers: { 'X-DevModePoll': 'true' } });
58+
if (response.headers.has('X-DevModePending')) {
59+
setTimeout(poll, delay);
60+
} else {
61+
// App ready
62+
document.location.reload();
63+
}
64+
} catch (e) {
65+
setTimeout(poll, delay);
66+
}
67+
};
7068

71-
</script>
72-
</head>
73-
<body>
74-
<div class="message">
75-
Building front-end development bundle
76-
</div>
77-
</body>
69+
setTimeout(poll, delay);
70+
</script>
71+
</head>
72+
<body>
73+
<div class="message">Building front-end development bundle</div>
74+
</body>
7875
</html>

0 commit comments

Comments
 (0)