mirror of
https://github.com/novnc/noVNC.git
synced 2026-05-26 23:19:41 +00:00
Fix disconnect crash when screen doesn't exist
The function removeChild throws an exception when the element specified doesn't exist. This can happen when opening the websocket throws an exception during connect. Fixes issue #979
This commit is contained in:
11
core/rfb.js
11
core/rfb.js
@@ -433,7 +433,16 @@ RFB.prototype = {
|
||||
this._mouse.ungrab();
|
||||
this._sock.close();
|
||||
this._print_stats();
|
||||
this._target.removeChild(this._screen);
|
||||
try {
|
||||
this._target.removeChild(this._screen);
|
||||
} catch (e) {
|
||||
if (e.name === 'NotFoundError') {
|
||||
// Some cases where the initial connection fails
|
||||
// can disconnect before the _screen is created
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
clearTimeout(this._resizeTimeout);
|
||||
Log.Debug("<< RFB.disconnect");
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user