serverpod / serverpod

Serverpod is a next-generation app and web server, explicitly built for the Flutter and Dart ecosystem.
BSD 3-Clause "New" or "Revised" License
2.3k stars 200 forks source link

Trying to dispose a StreamingConnectionHandler #2261

Closed Katekko closed 2 days ago

Katekko commented 2 weeks ago

Describe the bug Trying to dispose a StreamingConnectionHandler, line 55 its adding another _onConnectionStatusChanged, I don't think this is right. I was trying to dipose all the elements in my controller but it keep duplicating my streams and I found out why.

Lemme know if this is the expected, if is not, I will create a PR to fix this (changing to removeStreamingConnection)

image

To Reproduce Steps to reproduce the behavior:

  1. Just try to use the dispose method on StreamingConnectionHandler

Expected behavior Maybe remove the stream from client? image

Serverpod versions

Platform information I'm running in windows

Katekko commented 2 weeks ago

@Isakdl can you confirm for me?

BenAuerDev commented 1 week ago

@Katekko is it duplicating the stream itself or the items within the stream?

Katekko commented 1 week ago

@Katekko is it duplicating the stream itself or the items within the stream?

The stream. Instead removing the stream in the client, its adding the same listener in the dispose method. I guess this need to be the remove instead the add

Katekko commented 1 week ago

Let me clarify what I meant earlier. The issue isn't with the stream itself but with the duplication of the listener. Specifically, another listener is being added in the dispose method, even though a listener is already added when the StreamingConnectionHandler is created. If the listener wasn't added in the constructor, then the dispose method shouldn't be responsible for adding it either.

I created a pull request to address this issue by changing the line to remove the listener: https://github.com/serverpod/serverpod/pull/2287