core: Ignore websocket errors when navigating away from the page (ie, Abnormal closure when switching apps). #60
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Build Tilde Friends / Build-All (push) Successful in 32m21s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Build Tilde Friends / Build-All (push) Successful in 32m21s
				
			This commit is contained in:
		@@ -8,6 +8,7 @@ let gFiles = {};
 | 
				
			|||||||
let gApp = {files: {}, emoji: '📦'};
 | 
					let gApp = {files: {}, emoji: '📦'};
 | 
				
			||||||
let gEditor;
 | 
					let gEditor;
 | 
				
			||||||
let gOriginalInput;
 | 
					let gOriginalInput;
 | 
				
			||||||
 | 
					let gUnloading;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let kErrorColor = '#dc322f';
 | 
					let kErrorColor = '#dc322f';
 | 
				
			||||||
let kDisconnectColor = '#f00';
 | 
					let kDisconnectColor = '#f00';
 | 
				
			||||||
@@ -1560,27 +1561,31 @@ function connectSocket(path) {
 | 
				
			|||||||
			_receive_websocket_message(JSON.parse(event.data));
 | 
								_receive_websocket_message(JSON.parse(event.data));
 | 
				
			||||||
		};
 | 
							};
 | 
				
			||||||
		gSocket.onclose = function (event) {
 | 
							gSocket.onclose = function (event) {
 | 
				
			||||||
			const k_codes = {
 | 
								if (gUnloading) {
 | 
				
			||||||
				1000: 'Normal closure',
 | 
									setStatusMessage('⚪ Closing...', kStatusColor);
 | 
				
			||||||
				1001: 'Going away',
 | 
								} else {
 | 
				
			||||||
				1002: 'Protocol error',
 | 
									const k_codes = {
 | 
				
			||||||
				1003: 'Unsupported data',
 | 
										1000: 'Normal closure',
 | 
				
			||||||
				1005: 'No status received',
 | 
										1001: 'Going away',
 | 
				
			||||||
				1006: 'Abnormal closure',
 | 
										1002: 'Protocol error',
 | 
				
			||||||
				1007: 'Invalid frame payload data',
 | 
										1003: 'Unsupported data',
 | 
				
			||||||
				1008: 'Policy violation',
 | 
										1005: 'No status received',
 | 
				
			||||||
				1009: 'Message too big',
 | 
										1006: 'Abnormal closure',
 | 
				
			||||||
				1010: 'Missing extension',
 | 
										1007: 'Invalid frame payload data',
 | 
				
			||||||
				1011: 'Internal error',
 | 
										1008: 'Policy violation',
 | 
				
			||||||
				1012: 'Service restart',
 | 
										1009: 'Message too big',
 | 
				
			||||||
				1013: 'Try again later',
 | 
										1010: 'Missing extension',
 | 
				
			||||||
				1014: 'Bad gateway',
 | 
										1011: 'Internal error',
 | 
				
			||||||
				1015: 'TLS handshake',
 | 
										1012: 'Service restart',
 | 
				
			||||||
			};
 | 
										1013: 'Try again later',
 | 
				
			||||||
			setStatusMessage(
 | 
										1014: 'Bad gateway',
 | 
				
			||||||
				'🔴 Closed: ' + (k_codes[event.code] || event.code),
 | 
										1015: 'TLS handshake',
 | 
				
			||||||
				kDisconnectColor
 | 
									};
 | 
				
			||||||
			);
 | 
									setStatusMessage(
 | 
				
			||||||
 | 
										'🔴 Closed: ' + (k_codes[event.code] || event.code),
 | 
				
			||||||
 | 
										kDisconnectColor
 | 
				
			||||||
 | 
									);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		};
 | 
							};
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -1854,6 +1859,9 @@ window.addEventListener('load', function () {
 | 
				
			|||||||
	window.addEventListener('blur', blur);
 | 
						window.addEventListener('blur', blur);
 | 
				
			||||||
	window.addEventListener('message', message, false);
 | 
						window.addEventListener('message', message, false);
 | 
				
			||||||
	window.addEventListener('online', connectSocket);
 | 
						window.addEventListener('online', connectSocket);
 | 
				
			||||||
 | 
						window.addEventListener('beforeunload', function () {
 | 
				
			||||||
 | 
							gUnloading = true;
 | 
				
			||||||
 | 
						});
 | 
				
			||||||
	document.getElementById('name').value = window.location.pathname;
 | 
						document.getElementById('name').value = window.location.pathname;
 | 
				
			||||||
	document
 | 
						document
 | 
				
			||||||
		.getElementById('closeEditor')
 | 
							.getElementById('closeEditor')
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user