aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/webcrypto/CryptoAlgorithm.cpp
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-07-28 01:33:00 -0700
committerGravatar GitHub <noreply@github.com> 2023-07-28 01:33:00 -0700
commite110ccf84d8d9034e82a79bf7abf1fa92b2370be (patch)
treea4be8d322c2c61b767abce74ad670eeb65620b2e /src/bun.js/bindings/webcrypto/CryptoAlgorithm.cpp
parentc2a744f0cc1af080b2803e8b3b678bdaa4a1d14f (diff)
downloadbun-e110ccf84d8d9034e82a79bf7abf1fa92b2370be.tar.gz
bun-e110ccf84d8d9034e82a79bf7abf1fa92b2370be.tar.zst
bun-e110ccf84d8d9034e82a79bf7abf1fa92b2370be.zip
Fixes #3795 (#3856)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/bun.js/bindings/webcrypto/CryptoAlgorithm.cpp')
-rw-r--r--src/bun.js/bindings/webcrypto/CryptoAlgorithm.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/bun.js/bindings/webcrypto/CryptoAlgorithm.cpp b/src/bun.js/bindings/webcrypto/CryptoAlgorithm.cpp
index ca3b97bff..3c958bdfc 100644
--- a/src/bun.js/bindings/webcrypto/CryptoAlgorithm.cpp
+++ b/src/bun.js/bindings/webcrypto/CryptoAlgorithm.cpp
@@ -95,10 +95,12 @@ ExceptionOr<size_t> CryptoAlgorithm::getKeyLength(const CryptoAlgorithmParameter
template<typename ResultCallbackType, typename OperationType>
static void dispatchAlgorithmOperation(WorkQueue& workQueue, ScriptExecutionContext& context, ResultCallbackType&& callback, CryptoAlgorithm::ExceptionCallback&& exceptionCallback, OperationType&& operation)
{
+ context.refEventLoop();
workQueue.dispatch(
[operation = WTFMove(operation), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), contextIdentifier = context.identifier()]() mutable {
auto result = operation();
- ScriptExecutionContext::postTaskTo(contextIdentifier, [result = crossThreadCopy(WTFMove(result)), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback)](auto&) mutable {
+ ScriptExecutionContext::postTaskTo(contextIdentifier, [result = crossThreadCopy(WTFMove(result)), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback)](auto& context) mutable {
+ context.unrefEventLoop();
if (result.hasException()) {
exceptionCallback(result.releaseException().code());
return;