Skip to content

Commit fe96544

Browse files
hoxyqfacebook-github-bot
authored andcommitted
Add a getter for enabling console.createTask (facebook#54283)
Summary: # Changelog: [Internal] This will control scenarios when we enable `console.createTask` implementation, and when we just use the stub version. Reviewed By: huntie Differential Revision: D85440641
1 parent 6741322 commit fe96544

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

packages/react-native/ReactCommon/jsinspector-modern/RuntimeTarget.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,18 @@ bool RuntimeTarget::isDomainEnabled(Domain domain) const {
248248
return threadSafeDomainStatus_[domain];
249249
}
250250

251+
bool RuntimeTarget::isConsoleCreateTaskEnabled() const {
252+
if (isDomainEnabled(Domain::Runtime)) {
253+
return true;
254+
}
255+
256+
if (auto tracingAgent = tracingAgent_.lock()) {
257+
return tracingAgent->isRunningInBackgroundMode();
258+
}
259+
260+
return false;
261+
}
262+
251263
RuntimeTargetController::RuntimeTargetController(RuntimeTarget& target)
252264
: target_(target) {}
253265

packages/react-native/ReactCommon/jsinspector-modern/RuntimeTarget.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,10 @@ class JSINSPECTOR_EXPORT RuntimeTarget : public EnableExecutorFromThis<RuntimeTa
292292
* Install the console API handler.
293293
*/
294294
void installConsoleHandler();
295+
/**
296+
* Returns whether console.createTask should actually capture stack traces.
297+
*/
298+
bool isConsoleCreateTaskEnabled() const;
295299

296300
/**
297301
* Installs __DEBUGGER_SESSION_OBSERVER__ object on the JavaScript's global

0 commit comments

Comments
 (0)