MCPcopy Create free account
hub / github.com/Snapchat/Valdi / captureStackTraces

Method captureStackTraces

valdi/src/valdi/runtime/JavaScript/JavaScriptRuntime.cpp:3578–3624  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3576 }
3577 }
3578
3579 exceptionTracker.clearError();
3580
3581 _symbolicating = false;
3582 return error;
3583}
3584
3585void JavaScriptRuntime::onUnhandledRejectedPromise(IJavaScriptContext& jsContext, const JSValue& promiseResult) {
3586 auto currentContext = Context::currentRef();
3587
3588 bool shouldCrash = false;
3589
3590 if (notifyErrorHandler(jsContext, _unhandledRejectionHandler, currentContext, promiseResult, shouldCrash)) {
3591 return;
3592 }
3593
3594 JSExceptionTracker exceptionTracker(jsContext);
3595 auto value = jsValueToValue(jsContext, promiseResult, ReferenceInfoBuilder(), exceptionTracker);
3596 exceptionTracker.clearError();
3597
3598 if (value.isError()) {
3599 handleUncaughtJsErrorNoHandler(currentContext, value.getError(), /* isUnhandledPromise */ true, shouldCrash);
3600 } else {
3601 handleUncaughtJsErrorNoHandler(
3602 currentContext, Error(value.toStringBox()), /* isUnhandledPromise */ true, shouldCrash);
3603 }
3604}
3605
3606Ref<JSStackTraceProvider> JavaScriptRuntime::captureCurrentStackTrace() {
3607 if (_javaScriptContext == nullptr) {
3608 return nullptr;
3609 }
3610
3611 // Debugger and force flags always enable stack trace capture
3612 bool shouldCapture = _forceStackTraceCapture || _enableDebugger;
3613
3614 auto listener = getListener();
3615 if (!shouldCapture && listener && isInJsThread()) {
3616 auto currentContext = Context::currentRef();
3617 if (currentContext != nullptr && !currentContext->getScopeName().isEmpty()) {
3618 auto runtimeTweaks = listener->getRuntimeTweaks();
3619 shouldCapture = runtimeTweaks != nullptr && runtimeTweaks->enableScopedContextStackTraceCapture();
3620 }
3621 }
3622
3623 if (!shouldCapture) {
3624 return nullptr;
3625 }
3626
3627 return doCaptureCurrentStackTrace(*_javaScriptContext);

Callers 2

onANRMethod · 0.45

Calls 12

requestInterruptMethod · 0.80
setCapturedStacktraceMethod · 0.80
finishedCaptureMethod · 0.80
chronoMethod · 0.80
getCapturedStacktraceMethod · 0.80
StringBoxClass · 0.70
startMethod · 0.65
valueMethod · 0.65
isCurrentMethod · 0.45
asyncMethod · 0.45
elapsedMethod · 0.45

Tested by

no test coverage detected