Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

Socket cleanup on unload (#317)

Deepak K49df1a2e341c
diff --git a/frontend/src/helpers/SocketContext.js b/frontend/src/helpers/SocketContext.js
index 9dcf78bef..fa8d32e17 100644
--- a/frontend/src/helpers/SocketContext.js
+++ b/frontend/src/helpers/SocketContext.js
@@ -22,7 +22,10 @@ const SocketProvider = ({ children }) => {
}
const newSocket = io(baseUrl, body);
setSocket(newSocket);
-
+ // Clean up the socket connection on browser unload
+ window.onbeforeunload = () => {
+ newSocket.disconnect();
+ };
// Clean up the socket connection on component unmount
return () => {
newSocket.disconnect();