mirror of
https://github.com/oven-sh/bun
synced 2026-02-15 21:32:05 +00:00
Synchronously dispatch close event
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user