-
Notifications
You must be signed in to change notification settings - Fork 343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable FinalizationRegistry #3560
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1097,11 +1097,6 @@ void IoContext::runImpl(Runnable& runnable, | |
// Running the microtask queue can itself trigger a pending exception in the isolate. | ||
v8::TryCatch tryCatch(workerLock.getIsolate()); | ||
|
||
// Just trying out stuff | ||
auto& system = const_cast<jsg::V8System&>(js.getV8System()); | ||
while (v8::platform::PumpMessageLoop(&system.getDefaultPlatform(), js.v8Isolate, v8::platform::MessageLoopBehavior::kDoNotWait)) {} | ||
|
||
|
||
js.runMicrotasks(); | ||
|
||
if (tryCatch.HasCaught()) { | ||
|
@@ -1164,6 +1159,17 @@ void IoContext::runImpl(Runnable& runnable, | |
} | ||
} | ||
}); | ||
|
||
if (!isCurrentNull()) { | ||
KJ_LOG(ERROR, "IoContext not-null before running PumpMessageLoop()"); | ||
} else { | ||
worker->runInLockScope(lockType, [&](Worker::Lock& lock) { | ||
jsg::Lock& js = lock; | ||
auto& system = const_cast<jsg::V8System&>(js.getV8System()); | ||
KJ_DBG(js.v8Isolate); | ||
while (v8::platform::PumpMessageLoop(&system.getDefaultPlatform(), js.v8Isolate, v8::platform::MessageLoopBehavior::kDoNotWait)) {} | ||
jasnell marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It feels wrong for this code to be aware of the v8::Platform. Knowledge of how the platform is set up (and even the fact that we use the default platform) should be encapsulated inside JSG. To that end, perhaps There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this actually the right time to call PumpMessageLoop -- at the end of every single Arguably it might be preferable if we invoked There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that we likely need to find a better place for this. We can end up running ctx.run quite a few times during a request. |
||
}); | ||
} | ||
} | ||
|
||
static constexpr auto kAsyncIoErrorMessage = | ||
|
@@ -1191,6 +1197,10 @@ bool IoContext::hasCurrent() { | |
return threadLocalRequest != nullptr; | ||
} | ||
|
||
bool IoContext::isCurrentNull() { | ||
return threadLocalRequest == nullptr; | ||
} | ||
ketanhwr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
bool IoContext::isCurrent() { | ||
return this == threadLocalRequest; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taking a new lock here, immediately after releasing the previous one, is expensive. You should find a way to run PumpMessageLoop() just before releasing the previous lock instead.