File tree Expand file tree Collapse file tree 2 files changed +9
-11
lines changed
Expand file tree Collapse file tree 2 files changed +9
-11
lines changed Original file line number Diff line number Diff line change 11let ws : WebSocket ;
22
3- let closed = false ;
4-
53let reconnectTimer : number ;
64const backoff = [
75 0 ,
@@ -25,7 +23,7 @@ const backoff = [
2523] ;
2624let backoffIdx = 0 ;
2725function reconnect ( ) {
28- if ( ! closed ) return ;
26+ if ( ws . readyState !== ws . CLOSED ) return ;
2927
3028 reconnectTimer = setTimeout ( ( ) => {
3129 if ( backoffIdx === 0 ) {
@@ -39,7 +37,6 @@ function reconnect() {
3937
4038 try {
4139 connect ( true ) ;
42- closed = false ;
4340 clearTimeout ( reconnectTimer ) ;
4441 } catch ( _err ) {
4542 reconnect ( ) ;
@@ -54,18 +51,19 @@ function connect(forceReload?: boolean) {
5451 ) ;
5552
5653 ws . addEventListener ( "open" , ( ) => {
57- console . log (
58- `%c Fresh %c Connected to development server.` ,
59- "background-color: #86efac; color: black" ,
60- "color: inherit" ,
61- ) ;
6254 if ( forceReload ) {
6355 location . reload ( ) ;
56+ } else {
57+ backoffIdx = 0 ;
58+ console . log (
59+ `%c Fresh %c Connected to development server.` ,
60+ "background-color: #86efac; color: black" ,
61+ "color: inherit" ,
62+ ) ;
6463 }
6564 } ) ;
6665
6766 ws . addEventListener ( "close" , ( ) => {
68- closed = true ;
6967 reconnect ( ) ;
7068 } ) ;
7169
Original file line number Diff line number Diff line change 11import "preact/debug" ;
2- import "./client.ts" ;
2+ import ".. /client.ts" ;
33export * from "./main.ts" ;
You can’t perform that action at this time.
0 commit comments