Unblock React Compiler for 13 components by hoisting finally blocks

React Compiler cannot lower a `finally` block, so every component containing
one is skipped entirely. In these 24 sites the `catch` completes normally and
neither block returns or throws, which makes `finally { cleanup() }` exactly
equivalent to running `cleanup()` after the try/catch.

Sites with no `catch` are left alone - there the cleanup also runs on the throw
path, so hoisting it would change behavior.

Skipped components: 125 -> 112.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tomek Zawadzki
2026-08-25 15:41:19 +02:00
parent f87fdd2ea2
commit 5e30fb4454
19 changed files with 39 additions and 63 deletions
+1 -2
View File
@@ -126,9 +126,8 @@ function InnerApp() {
}
} catch (e) {
logger.warn(`session: resume failed`, {message: e})
} finally {
setIsReady(true)
}
setIsReady(true)
}
const account = readLastActiveAccount()
void onLaunch(account)
+1 -2
View File
@@ -105,9 +105,8 @@ function InnerApp() {
}
} catch (e) {
logger.warn('session: resumeSession failed', {message: e})
} finally {
setIsReady(true)
}
setIsReady(true)
}
const account = readLastActiveAccount()
void onLaunch(account)
@@ -429,14 +429,13 @@ let PostMenuItems = ({
type: 'error',
})
}
} finally {
ax.metric('postMenu:blockAccount', {
uri: postUri,
authorDid: postAuthor.did,
logContext,
feedDescriptor: feedFeedback.feedDescriptor,
})
}
ax.metric('postMenu:blockAccount', {
uri: postUri,
authorDid: postAuthor.did,
logContext,
feedDescriptor: feedFeedback.feedDescriptor,
})
}
const onMuteAuthor = async () => {
@@ -452,14 +451,13 @@ let PostMenuItems = ({
type: 'error',
})
}
} finally {
ax.metric('postMenu:unmuteAccount', {
uri: postUri,
authorDid: postAuthor.did,
logContext,
feedDescriptor: feedFeedback.feedDescriptor,
})
}
ax.metric('postMenu:unmuteAccount', {
uri: postUri,
authorDid: postAuthor.did,
logContext,
feedDescriptor: feedFeedback.feedDescriptor,
})
} else {
try {
await queueMute()
@@ -472,14 +470,13 @@ let PostMenuItems = ({
type: 'error',
})
}
} finally {
ax.metric('postMenu:muteAccount', {
uri: postUri,
authorDid: postAuthor.did,
logContext,
feedDescriptor: feedFeedback.feedDescriptor,
})
}
ax.metric('postMenu:muteAccount', {
uri: postUri,
authorDid: postAuthor.did,
logContext,
feedDescriptor: feedFeedback.feedDescriptor,
})
}
}
@@ -95,9 +95,8 @@ function DeviceLocationRequestDialogInner({onLocationAcquired}: Props) {
safeMessage: e.message,
})
}
} finally {
setIsRequesting(false)
}
setIsRequesting(false)
}
return (
@@ -241,9 +241,8 @@ export function PostInteractionSettingsDialogControlledInner(
type: 'error',
},
)
} finally {
setIsSaving(false)
}
setIsSaving(false)
}, [
_,
ax,
@@ -319,9 +319,8 @@ function Inner(
type: 'setError',
error,
})
} finally {
setIsPending(false)
}
setIsPending(false)
}, [logger, submitReport, props, state, ax, l, videoTimestampSeconds])
useCallOnce(() => {
+1 -2
View File
@@ -54,9 +54,8 @@ export function useAccountSwitcher() {
Toast.show(_(msg`Please sign in as @${account.handle}`), {
type: 'warning',
})
} finally {
setPendingDid(null)
}
setPendingDid(null)
},
[_, ax, resumeSession, requestSwitchToAccount, pendingDid],
)
+1 -2
View File
@@ -95,9 +95,8 @@ export function Deactivated() {
logger.error(e, {
message: 'Failed to activate account',
})
} finally {
setPending(false)
}
setPending(false)
}, [_, pdsClient, refreshSession, setPending, setError, queryClient])
return (
+1 -2
View File
@@ -103,9 +103,8 @@ export function ListHiddenScreen({
msg`There was an issue. Please check your internet connection and try again.`,
),
)
} finally {
setIsProcessing(false)
}
setIsProcessing(false)
}
return (
+1 -2
View File
@@ -58,9 +58,8 @@ export const ChooseAccountForm = ({
})
// Move to login form.
onSelectAccount(account)
} finally {
setPendingDid(null)
}
setPendingDid(null)
},
[
currentAccount,
@@ -102,9 +102,8 @@ function Inner() {
logger.error('Failed to request password reset', {safeMessage: e})
setError(cleanError(e))
}
} finally {
setIsProcessing(false)
}
setIsProcessing(false)
}
const onChangePassword = async () => {
@@ -151,9 +150,8 @@ function Inner() {
logger.error('Failed to set new password', {safeMessage: e})
setError(cleanError(e))
}
} finally {
setIsProcessing(false)
}
setIsProcessing(false)
}
const onBlur = () => {
@@ -64,9 +64,8 @@ function DeactivateAccountDialogInner({
logger.error(e, {
message: 'Failed to deactivate account',
})
} finally {
setPending(false)
}
setPending(false)
}, [client, control, logoutCurrentAccount, _, setPending])
return (
@@ -49,9 +49,8 @@ export function DisableEmail2FADialog({
setStage(Stages.ConfirmCode)
} catch (e) {
setError(cleanError(String(e)))
} finally {
setIsProcessing(false)
}
setIsProcessing(false)
}
const onConfirmDisable = async () => {
@@ -80,9 +79,8 @@ export function DisableEmail2FADialog({
} else {
setError(cleanError(e))
}
} finally {
setIsProcessing(false)
}
setIsProcessing(false)
}
return (
@@ -53,9 +53,8 @@ export function ExportCarDialog({
} catch (e) {
logger.error('Error occurred while downloading CAR file', {message: e})
Toast.show(l`Error occurred while saving file`, {type: 'error'})
} finally {
setLoading(false)
}
setLoading(false)
}, [l, currentAccount, pdsClient])
const downloadChatData = useCallback(async () => {
@@ -84,9 +83,8 @@ export function ExportCarDialog({
} catch (e) {
logger.error('Error occurred while downloading chat data', {message: e})
Toast.show(l`Error occurred while saving file`, {type: 'error'})
} finally {
setLoading(false)
}
setLoading(false)
}, [l, currentAccount, chatClient])
return (
+1 -2
View File
@@ -51,9 +51,8 @@ export function StepCaptchaNative() {
} catch (err) {
const e = err as Error
logger.error(e)
} finally {
setReady(true)
}
setReady(true)
})()
}, [])
+1 -2
View File
@@ -60,9 +60,8 @@ export function SignupQueued() {
}
} catch (e: any) {
logger.error('Failed to check signup queue', {err: e.toString()})
} finally {
setProcessing(false)
}
setProcessing(false)
}, [
setProcessing,
setEstimatedTime,
@@ -103,9 +103,8 @@ export function NotificationFeed({
logger.error('Failed to refresh notifications feed', {
message: err,
})
} finally {
setIsPTRing(false)
}
setIsPTRing(false)
}, [refreshNotifications, setIsPTRing])
const onEndReached = useCallback(async () => {
@@ -920,9 +920,8 @@ function SayHelloBtn({profile}: {profile: app.bsky.actor.defs.ProfileView}) {
})
} catch (e) {
logger.error('Failed to get conversation', {safeMessage: e})
} finally {
setIsLoading(false)
}
setIsLoading(false)
}
if (
+1 -2
View File
@@ -559,9 +559,8 @@ function ComposeBtn({minimal}: {minimal: boolean}) {
handle = await fetchHandle(handle)
} catch (e) {
handle = undefined
} finally {
setIsFetchingHandle(false)
}
setIsFetchingHandle(false)
}
if (