Page MenuHomePhabricator

[lib] Don't swallow errors in getUserIdentities() call
AbandonedPublic

Authored by angelika on Nov 14 2024, 12:51 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Dec 9, 6:47 PM
Unknown Object (File)
Mon, Dec 2, 12:31 AM
Unknown Object (File)
Fri, Nov 29, 8:26 AM
Unknown Object (File)
Mon, Nov 25, 1:00 AM
Unknown Object (File)
Sun, Nov 24, 5:11 PM
Unknown Object (File)
Fri, Nov 22, 5:38 PM
Unknown Object (File)
Fri, Nov 22, 3:37 PM
Unknown Object (File)
Nov 20 2024, 1:18 PM
Subscribers

Details

Reviewers
tomek
kamil
ashoat
Summary
Test Plan
  1. Throw some error in fetchUserIdentitiesPromise() so that finding user indentity always fails
  2. Mobile user goes to profile -> Friend list and adds the web user as a friend
  3. Before a thin thread was created. Now mobile user sees an alert, because there is no auxUserInfo, no thick thread and call to identity server fails.

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

This is a scary change... it affects all callers of useFindUserIdentities:

  • FarcasterDataHandler
  • UserInfosHandler
  • useSendDMOperationUtils
  • useThreadListSearch via useUsersSupportThickThreads
  • useUserProfileThreadInfo via useUsersSupportThickThreads
  • Thread composer code (ConnectedMessageListContainer on native, ChatThreadComposer on web) via useUsersSupportThickThreads
  • useThreadInfoForPossiblyPendingThread on web via useUsersSupportThickThreads
  • useUpdateRelationships (after D13938, via useUsersSupportThickThreads)

Is this really safe for all of those callers?

I'm also a bit confused as to why this is necessary or what it accomplishes. I re-read through the Linear task but couldn't find anything. Could you explain why we want to stop swallowing errors here?

I'm also a bit confused as to why this is necessary or what it accomplishes. I re-read through the Linear task but couldn't find anything. Could you explain why we want to stop swallowing errors here?

With swallowing errors in case findUserIdentities fails because for example there is no internet connection, a thin thread will be created.
Without swallowing errors an error message will be shown to the user and no thread is created.

Also this swallowing errors in general causes confusion and bugs that are hard to debug.

  1. Request or something fails because there is no internet connection or backend is down (which is expected)
  2. We swallow the error, log it and move along
  3. Sometimes a weird behaviour is happening (like in this case thin threads created)
  4. We report a bug without logs
  5. We have a bug that is hard to debug and it's hard to figure out what went wrong

It happened at least 2-3 times already in the month I was here. Expected errors like this should be handled.

ashoat requested changes to this revision.Nov 18 2024, 5:42 AM

Thanks @angelika. Some concerns:

  • Your test plan is insufficient. You're modifying 8-10 callsites and have not tested all of them. At the very least, I'd expect you to read through each callsite and analyze what would happen if this function threw an exception, as currently it never throws exceptions. (You can document analysis like this in the Test Plan section, even if it technically doesn't count as testing.)
  • While I understand where you're coming from, this breaks a pattern in all of our caching code. You'll find in ENSCache, FCCache, etc. that we always handle a timeout this way.
  • Beyond breaking a pattern, I'm not sure I agree with the general thinking here. It's true that swallowing exceptions can sometimes lead to unexpected behavior. But, similarly, throwing exceptions instead of swallowing them can lead to certain codepaths being broken. I think it sometimes makes sense to swallow exceptions, and it doesn't seem like you've done an exhaustive analysis of callsites to determine which pattern makes more sense.

I'd be open to rethinking this, but I would need two things:

  1. Evidence that you've analyzed each callsite and determined what the impact is.
  2. More details regarding "it happened at least 2-3 times already in the month I was here": detail each case, and how it was caused by this issue.

As an alternative, if there is a specific callsite (perhaps useUpdateRelationships?) where you think this error should not be swallowed, it seems like it would be better to address that callsite directly, by differentiating between null and undefined results.

This revision now requires changes to proceed.Nov 18 2024, 5:42 AM