Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix connection crash bug #579

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/OnyxConnectionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class OnyxConnectionManager {
* Adds the connection to the eviction block list. Connections added to this list can never be evicted.
* */
addToEvictionBlockList(connection: Connection): void {
const connectionMetadata = this.connectionsMap.get(connection.id);
const connectionMetadata = this.connectionsMap.get(connection?.id);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just return early above if connection is undefined before trying to access the key?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@getusha We already have a check to return early if connectionMetadata so I think we can do this and no need to add a new if condition

if (!connectionMetadata) {
return;
}
Expand All @@ -245,7 +245,7 @@ class OnyxConnectionManager {
* which will enable it to be evicted again.
*/
removeFromEvictionBlockList(connection: Connection): void {
const connectionMetadata = this.connectionsMap.get(connection.id);
const connectionMetadata = this.connectionsMap.get(connection?.id);
if (!connectionMetadata) {
return;
}
Expand Down
Loading