-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak if onopen event received after we close a component. #12
Comments
Thank you for clarifying this edge case that has existed for some time. My personal projects called The fix, unfortunately, requires heavily changing the existing interface to the library, so I will be working on a v2 for this. |
Let me know, if there is some code to test or review :-) |
I've published a release candidate for v2, though I still need to update the readme. https://github.com/tserkov/vue-sse/tree/v2 I've also created an example application: https://github.com/tserkov/vue-sse-example This version creates everything @sbernard31 has requested, and includes typescript definitions. |
I played a little bit with it. I think maybe we should add a shortcut for If I well understand there is no more So the code looks like : <template>
<div>
<p v-for="message in messages" :key="message.id">{{ message }}</p>
</div>
</template>
<script>
export default {
name: "sse-test",
data() {
return {
messages: [],
};
},
mounted() {
this.sse = this.$sse
.create({ url: "/your-events-server" })
.on("chat", (message) => {
this.messages.push(message);
})
.connect()
.catch((err) => {
console.error("Failed to connect to server", err);
});
},
beforeDestroy() {
this.sse.disconnect();
},
};
</script> I didn't find anything about #13 ? I think if the disconnect could be done automatically by default this could be great. <template>
<div>
<p v-for="message in messages" :key="message.id">{{ message }}</p>
</div>
</template>
<script>
export default {
name: "sse-test",
data() {
return {
messages: [],
};
},
mounted() {
this.$sse
.create("/your-events-server")
.on("chat", (message) => {
this.messages.push(message);
})
.connect()
.catch((err) => {
console.error("Failed to connect to server", err);
});
},
};
</script> |
Thank you for your feedback. I will work to make the first parameter to I did remove the old I haven't implemented #13 yet -- it's a complicated thing to do. I will somehow need to associate an instance of |
👍 I did remove the old onError system, since consumers can simply add it as a handler: mysse.on('error', () => /* react to connection outage */);. This will be updated in the README. 👍
Yep I understand let's talk about his in #13. |
My previous test show that v2 fixed this bug so I guess we can close this bug ? Do you need an issue for :
|
I begin to play with
vue-sse
and I maybe find an issue.My code looks like :
This sounds OK but for a reason I can not explain for now the
onopen
call take a lot of time before to be called. (I don't know if this is an issue but this reveals what it looks like a real design issue)Here is the normal use case :
Now this is the failing use case where I close my view before to get connected
It seems to me that my usecase is a "classic" one and so unless I missed something there is maybe a design issue ? 🤔
Adapting
vue-sse
code to get thewrapper object
immediatly without waiting theonopen
event (like proposed in #7), this resolved my issue.If there is no issue in the code and if there is a good way to handle this, I guess there is at least an issue in README examples.
The text was updated successfully, but these errors were encountered: