Skip to content
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

Removing a Websocket Errors #160

Open
Parker-Bergen opened this issue Apr 25, 2022 · 9 comments
Open

Removing a Websocket Errors #160

Parker-Bergen opened this issue Apr 25, 2022 · 9 comments

Comments

@Parker-Bergen
Copy link

Hi, I am currently rending a Websocket when I need to, but when I stop render the Websocket , remove it from children of an object, the Websocket will try to push its props back to the child resulting in an error since non of the object information about the Websocket component exists.
Is there a way around this or to stop the Websocket from pushing its props on close?
Children should be empty but instead gets filled with the below info:
image_2022-04-25_170036973

@emilhe
Copy link
Owner

emilhe commented Apr 26, 2022

Could you provide a MWE in code?

@Parker-Bergen
Copy link
Author

Below I have linked a basic server from your documentation and then the client server with the breaking websockets.
I have added them as txts because .py is not allowed and I could not paste them nicely.
Websocket Delete Example.txt
Delete Example Server.txt

@emilhe
Copy link
Owner

emilhe commented May 2, 2022

For code, please use the markdown code blocks available in the editor by clicking the <> symbol. The easiest is typically to pasta a block of code, then highlight the code and click the <> symbol.

I just tried running your example, and I get the error. But it doesn't seem related to the websocket, the error seems related to bugs in the way children are being manipulated in the update_output_sockets callback.

@Parker-Bergen
Copy link
Author

For some reason when I wrapped the code in the code block it excluded large parts of the code.
In relation to the error, although it is a children problem, it is stemmed from when I remove the websocket child. The websocket disconnects and as a result the websocket tries to write its state to the previously existing websocket component, however that no longer exists and so it is just written in the children, but that set of info is not a component and so the dashboard errors. If there is a way to prevent this state from updating or checking if the component still exists before writing, I believe it would solve the issue as the component will not try and write its final death state.

@KristofferFogh04
Copy link

Hi, I suspect that I currently have the same problem using websockets in my dash project, so I wanted to know if there is any news on this? My scenario is that I have a dash app with multiple pages and I only want to keep a websocket connection open if the user is on one specific page. I can connect to the websocket on that specific page, but when I try to change the page (and thereby close and unload the websocket) the app crashes. I hope to hear any updates you might have. Thanks!

@emillma
Copy link

emillma commented Jan 18, 2023

Hi, I have encountered the same issue when using a WebSocket in a multipage app and changing away from a page containing one ore more unclosed WebSockets. The full traceback is:

(This error originated from the built-in JavaScript code that runs Dash apps. Click to see the full stack trace or open your browser's console.)
TypeError: t.split is not a function

    at u.value (http://localhost:8050/_dash-component-suites/dash/dcc/async-markdown.js:2:5115)

    at u.value (http://localhost:8050/_dash-component-suites/dash/dcc/async-markdown.js:2:6646)

    at finishClassComponent (http://localhost:8050/_dash-component-suites/dash/deps/[email protected]_7_0m1669813432.14.0.js:17295:33)

    at updateClassComponent (http://localhost:8050/_dash-component-suites/dash/deps/[email protected]_7_0m1669813432.14.0.js:17245:26)

    at beginWork (http://localhost:8050/_dash-component-suites/dash/deps/[email protected]_7_0m1669813432.14.0.js:18755:18)

    at HTMLUnknownElement.callCallback (http://localhost:8050/_dash-component-suites/dash/deps/[email protected]_7_0m1669813432.14.0.js:182:16)

    at Object.invokeGuardedCallbackDev (http://localhost:8050/_dash-component-suites/dash/deps/[email protected]_7_0m1669813432.14.0.js:231:18)

    at invokeGuardedCallback (http://localhost:8050/_dash-component-suites/dash/deps/[email protected]_7_0m1669813432.14.0.js:286:33)

    at beginWork$1 (http://localhost:8050/_dash-component-suites/dash/deps/[email protected]_7_0m1669813432.14.0.js:23338:9)

    at performUnitOfWork (http://localhost:8050/_dash-component-suites/dash/deps/[email protected]_7_0m1669813432.14.0.js:22292:14)

@m3g4p0p
Copy link

m3g4p0p commented Mar 3, 2023

Hi, I also have this issue and it could probably be resolved exactly like @Parker-Bergen suggested... just remove the onclose callback before closing the connection inside componentWillUnmount():

https://github.com/thedirtyfew/dash-extensions/blob/master/src/lib/components/WebSocket.react.js#L78

PS: Actually, remove all callbacks here just to be safe and avoid memory leaks. ^^

@emilhe
Copy link
Owner

emilhe commented Mar 13, 2023

I have just pushed an rc release with a potential fix. Could you test if it resolves your issues @m3g4p0p ?

https://pypi.org/project/dash-extensions/0.1.14rc1/

@m3g4p0p
Copy link

m3g4p0p commented Mar 14, 2023

Hi @emilhe, yes cool many thanks, that seems to have fixed the issue. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants