Files
orca/mobile/src/diagnostics/native-render-log.ts
T
Neil 19043a3d76 refactor(mobile): organize pairing, session, RPC and host owners (#39846)
* refactor(mobile): give relay and encryption concrete owners

* refactor(mobile): organize session and review feature owners

* refactor(mobile): organize RPC and host ownership

* test(mobile): point render fixtures at concrete owners

* refactor(mobile): use explicit type-only owner imports
2026-11-08 07:19:05 -08:00

33 lines
1.2 KiB
TypeScript

import { sanitizeCrashReportString } from '../../../src/shared/crash-report-redaction'
import { captureBridgeError } from '../mobile-web-shell/bridge/bridge-error-capture'
import { connectionLogStore } from './connection/persisted-connection-log-store'
export const NATIVE_APP_LOG_ID = 'orca:native-app'
let sequence = 0
export function recordNativeRenderError(error: unknown, route: string): void {
const ts = Date.now()
const category = captureBridgeError(error).category
let frames = ''
try {
if (error instanceof Error && typeof error.stack === 'string') {
// Only frames: multiline error messages can contain user content.
const prefix = `${error.name}: ${error.message}`
frames = (error.stack.startsWith(prefix) ? error.stack.slice(prefix.length) : '')
.split(/\r?\n/)
.filter((line) => /^\s+at /.test(line))
.join('\n')
}
} catch {
// A thrown value can have an unreadable stack getter.
}
connectionLogStore.append(NATIVE_APP_LOG_ID, {
id: `native-render-${ts}-${++sequence}`,
ts,
level: 'error',
code: 'native-render-failed',
message: 'Native screen failed to render',
detail: sanitizeCrashReportString(`/${route || 'index'}: ${category}\n${frames}`, 2_000)
})
}