bigskysoftware / htmx-extensions

164 stars 50 forks source link

maybeCloseWebSocketSource raises error #96

Open gilesbradshaw opened 1 month ago

gilesbradshaw commented 1 month ago

I am getting an error from maybeCloseWebSocketSource api.getInternalData(elt) does not have websocket property and web socket already closed by htmx:beforeCleanupElement event

function maybeCloseWebSocketSource(elt) {
        if (!api.bodyContains(elt)) {
            console.log('maybe closing web socket')
            const internalData = api.getInternalData(elt)
            if (internalData.webSocket) {
                internalData.webSocket.close();
                return true;
            }
            return false;
        }
        return false;
    }

it goes away..

ckampfe commented 1 week ago

I also get Uncaught TypeError: api.getInternalData(...).webSocket is undefined when making an htmx request that replaces the existing section of the document that has the ws-connect attribute on it.