From bed24f3a51dc4e4d0212aaae070096f10983b928 Mon Sep 17 00:00:00 2001 From: Alistair Smith Date: Fri, 30 May 2025 18:55:03 -0700 Subject: [PATCH] use RELEASE_ASSERT (https://github.com/oven-sh/bun/pull/19940#discussion_r2116938040) --- src/bun.js/bindings/ScriptExecutionContext.cpp | 4 ++-- src/bun.js/bindings/ScriptExecutionContext.h | 2 +- src/bun.js/bindings/webcore/MessagePort.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/bun.js/bindings/ScriptExecutionContext.cpp b/src/bun.js/bindings/ScriptExecutionContext.cpp index 103cb0ce1b..10be2f1813 100644 --- a/src/bun.js/bindings/ScriptExecutionContext.cpp +++ b/src/bun.js/bindings/ScriptExecutionContext.cpp @@ -125,14 +125,14 @@ void ScriptExecutionContext::unrefEventLoop() bool ScriptExecutionContext::canSendMessage() { us_loop_t* loop = (us_loop_t*)uws_get_loop(); - uint32_t currentTickNr = static_cast(us_loop_iteration_number(loop)); + long long currentTickNr = static_cast(us_loop_iteration_number(loop)); if (lastSendTickNr != currentTickNr) { messagesSentThisTick = 0; lastSendTickNr = currentTickNr; } - constexpr uint32_t MAX_MESSAGES_PER_TICK = 1000; + constexpr long long MAX_MESSAGES_PER_TICK = 1000; if (messagesSentThisTick >= MAX_MESSAGES_PER_TICK) { return false; } diff --git a/src/bun.js/bindings/ScriptExecutionContext.h b/src/bun.js/bindings/ScriptExecutionContext.h index 4d36305f2a..baa20f85c3 100644 --- a/src/bun.js/bindings/ScriptExecutionContext.h +++ b/src/bun.js/bindings/ScriptExecutionContext.h @@ -60,7 +60,7 @@ public: } uint32_t messagesSentThisTick = 0; - uint32_t lastSendTickNr = -1; // Will be updated to the us_loop_t->data.iteration_nr every tick we send a message in + long long lastSendTickNr = -1; // Will be updated to the us_loop_t->data.iteration_nr every tick we send a message in // https://github.com/oven-sh/bun/blob/d7a517cdfc31705a6b4fb696dc834ba8d98d5d3a/packages/bun-usockets/src/internal/loop_data.h#L58 bool canSendMessage(); diff --git a/src/bun.js/bindings/webcore/MessagePort.cpp b/src/bun.js/bindings/webcore/MessagePort.cpp index 1a6881041b..058f77d373 100644 --- a/src/bun.js/bindings/webcore/MessagePort.cpp +++ b/src/bun.js/bindings/webcore/MessagePort.cpp @@ -278,8 +278,8 @@ void MessagePort::processMessages(ScriptExecutionContext& context, VectorreportUncaughtExceptionAtEventLoop(globalObject, scope.exception()); - scope.clearExceptionExceptTermination(); + RELEASE_ASSERT(vm.hasPendingTerminationException()); + return; } if (Zig::GlobalObject::scriptExecutionStatus(globalObject, globalObject) == ScriptExecutionStatus::Running) {