From 5c2696207aa4ed3a2644a99ee79ecf5859947a02 Mon Sep 17 00:00:00 2001 From: Joshua Blum Date: Wed, 18 Mar 2026 15:56:19 -0400 Subject: [PATCH 1/2] set 100ms timeout on Linking.getInitialURL, more logs --- .../platform-specific/index.native.tsx | 17 ++++++++++++++++- shared/router-v2/hooks.native.tsx | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/shared/constants/platform-specific/index.native.tsx b/shared/constants/platform-specific/index.native.tsx index 2c8f08624117..338983951fdc 100644 --- a/shared/constants/platform-specific/index.native.tsx +++ b/shared/constants/platform-specific/index.native.tsx @@ -137,6 +137,8 @@ export const showShareActionSheet = async (options: { } const loadStartupDetails = async () => { + logger.info('[Startup] loadStartupDetails: starting') + const t = Date.now() const [routeState, initialUrl, push] = await Promise.all([ neverThrowPromiseFunc(async () => { try { @@ -146,7 +148,19 @@ const loadStartupDetails = async () => { return Promise.resolve('') } }), - neverThrowPromiseFunc(async () => Linking.getInitialURL()), + neverThrowPromiseFunc(async () => { + const linkingStart = Date.now() + logger.info('[Startup] loadStartupDetails: calling Linking.getInitialURL') + const timeout = new Promise(resolve => setTimeout(() => resolve(null), 100)) + const url = await Promise.race([Linking.getInitialURL(), timeout]) + const elapsed = Date.now() - linkingStart + if (url === null) { + logger.warn(`[Startup] loadStartupDetails: Linking.getInitialURL returned null/timed out in ${elapsed}ms`) + } else { + logger.info(`[Startup] loadStartupDetails: Linking.getInitialURL returned in ${elapsed}ms: ${url}`) + } + return url + }), neverThrowPromiseFunc(getStartupDetailsFromInitialPush), ] as const) @@ -192,6 +206,7 @@ const loadStartupDetails = async () => { tab = '' } + logger.info(`[Startup] loadStartupDetails: done in ${Date.now() - t}ms`) storeRegistry.getState('config').dispatch.setStartupDetails({ conversation: conversation ?? noConversationIDKey, followUser, diff --git a/shared/router-v2/hooks.native.tsx b/shared/router-v2/hooks.native.tsx index e957781818b8..4be4928cb44a 100644 --- a/shared/router-v2/hooks.native.tsx +++ b/shared/router-v2/hooks.native.tsx @@ -7,6 +7,7 @@ import {useDeepLinksState} from '@/constants/deeplinks' import {Linking} from 'react-native' import {useColorScheme} from 'react-native' import {usePushState} from '@/constants/push' +import logger from '@/logger' type InitialStateState = 'init' | 'loading' | 'loaded' @@ -177,6 +178,7 @@ export const useInitialState = (loggedInLoaded: boolean) => { const f = async () => { await loadInitialURL() + logger.info('[Router] initialStateState loaded, rendering app') setInitialStateState('loaded') } From ed12dad1baeada69f334d8032769395e611cc87b Mon Sep 17 00:00:00 2001 From: Joshua Blum Date: Wed, 18 Mar 2026 16:01:25 -0400 Subject: [PATCH 2/2] x --- shared/router-v2/hooks.native.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shared/router-v2/hooks.native.tsx b/shared/router-v2/hooks.native.tsx index 4be4928cb44a..6e51de3c3e3e 100644 --- a/shared/router-v2/hooks.native.tsx +++ b/shared/router-v2/hooks.native.tsx @@ -97,7 +97,8 @@ export const useInitialState = (loggedInLoaded: boolean) => { } setInitialStateState('loading') const loadInitialURL = async () => { - let url = await Linking.getInitialURL() + const timeout = new Promise(resolve => setTimeout(() => resolve(null), 100)) + let url = await Promise.race([Linking.getInitialURL(), timeout]) // don't try and resume or follow links if we're signed out if (!loggedIn) {