Skip to content

Commit 212a7ea

Browse files
authored
Merge pull request #79 from mrbot-ai/connection-leak-fix
fixed connection leak when closing down component
2 parents 3c01e65 + a2d4c96 commit 212a7ea

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
## 0.5.7
2+
- Fixed a bug where the connection would not close down when the component unmounted and continued polling indefinitely in the background.
3+
14
## 0.5.6
2-
- fixed a bug where named links would not render in a received message
5+
- Fixed a bug where named links would not render in a received message
36

47
## 0.5.5
5-
- new prop, `docViewer`, if this props is true, this will treat every link in received messages as a document and will open it in a popup using docs.google.com/viewer (note: this is an experimental feature and should be used with caution)
8+
- New prop, `docViewer`, if this props is true, this will treat every link in received messages as a document and will open it in a popup using docs.google.com/viewer (note: this is an experimental feature and should be used with caution)
69

710
## 0.5.4
811
- When reconnecting to an existing chat session, the bot will send a message contained in the localStorage key specified by the `NEXT_MESSAGE` constant. The message should be stringified JSON with a `message` property describing the message and an `expiry` property set to a UNIX timestamp in milliseconds after which this message should not be sent.

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)