Skip to content

Commit bc321aa

Browse files
committed
fixed connection leak when closing down component
1 parent 3c01e65 commit bc321aa

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/components/Widget/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ class Widget extends Component {
9090

9191
socket.on('disconnect', (reason) => {
9292
console.log(reason);
93-
this.props.dispatch(disconnectServer());
93+
if (reason !== 'io client disconnect') {
94+
this.props.dispatch(disconnectServer());
95+
}
9496
});
9597

9698
if (this.props.embedded && this.props.initialized) {
@@ -108,6 +110,11 @@ class Widget extends Component {
108110
}
109111
}
110112

113+
componentWillUnmount() {
114+
const { socket } = this.props;
115+
socket.close();
116+
}
117+
111118
getSessionId() {
112119
const { storage } = this.props;
113120
// Get the local session, check if there is an existing session_id

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const ConnectedWidget = (props) => {
1515
sock,
1616
storage,
1717
props.docViewer,
18-
);
18+
);
1919
return (<Provider store={store}>
2020
<Widget
2121
socket={sock}

0 commit comments

Comments
 (0)