diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bun.js/bindings/webcore/WebSocket.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/bun.js/bindings/webcore/WebSocket.cpp b/src/bun.js/bindings/webcore/WebSocket.cpp index 004b907b5..4cfe39f95 100644 --- a/src/bun.js/bindings/webcore/WebSocket.cpp +++ b/src/bun.js/bindings/webcore/WebSocket.cpp @@ -880,6 +880,11 @@ void WebSocket::didClose(unsigned unhandledBufferedAmount, unsigned short code, this->m_connectedWebSocketKind = ConnectedWebSocketKind::None; this->m_upgradeClient = nullptr; + if (this->hasEventListeners("close"_s)) { + this->dispatchEvent(CloseEvent::create(wasClean, code, reason)); + return; + } + if (auto* context = scriptExecutionContext()) { this->m_pendingActivityCount++; context->postTask([this, code, wasClean, reason, protectedThis = Ref { *this }](ScriptExecutionContext& context) { |