From 6367ecc7d58d298b01f884d7f80fe032c9815f47 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sat, 25 Jan 2025 03:37:46 -0800 Subject: [PATCH] Fix bug causing AbortSignal to sometimes collect too early (#16748) --- src/bun.js/bindings/webcore/AbortSignal.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bun.js/bindings/webcore/AbortSignal.cpp b/src/bun.js/bindings/webcore/AbortSignal.cpp index 7d22ef7a9b..8886fb57a0 100644 --- a/src/bun.js/bindings/webcore/AbortSignal.cpp +++ b/src/bun.js/bindings/webcore/AbortSignal.cpp @@ -195,6 +195,7 @@ void AbortSignal::cleanNativeBindings(void* ref) }); std::exchange(m_native_callbacks, WTFMove(callbacks)); + this->eventListenersDidChange(); } // https://dom.spec.whatwg.org/#abortsignal-follow @@ -218,7 +219,7 @@ void AbortSignal::signalFollow(AbortSignal& signal) void AbortSignal::eventListenersDidChange() { - m_hasAbortEventListener = hasEventListeners(eventNames().abortEvent); + m_hasAbortEventListener = hasEventListeners(eventNames().abortEvent) or !m_native_callbacks.isEmpty(); } uint32_t AbortSignal::addAbortAlgorithmToSignal(AbortSignal& signal, Ref&& algorithm)