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 subs bug #15680

Merged
merged 3 commits into from
Apr 18, 2023
Merged

fix subs bug #15680

merged 3 commits into from
Apr 18, 2023

Conversation

flexsurfer
Copy link
Member

@flexsurfer flexsurfer commented Apr 18, 2023

fixes #15678

sometimes you can see in re-frisk subscriptions run in the loop, that means there is a mistake in usage, and we should find and fix that

image

PS: actually it didn't solve the problem, so the review is on hold

PS2: fixed , so subscription must be called only by reagent when its initializing the view, but in this case it was run in the dismiss function outside of reagent context , which leads to subscription leak

ready for review

@status-im-auto
Copy link
Member

status-im-auto commented Apr 18, 2023

Jenkins Builds

Click to see older builds (4)
Commit #️⃣ Finished (UTC) Duration Platform Result
7895aa7 #1 2023-04-18 12:34:49 ~4 min tests 📄log
✔️ 7895aa7 #1 2023-04-18 12:36:20 ~5 min android 🤖apk 📲
✔️ 7895aa7 #1 2023-04-18 12:37:17 ~6 min android-e2e 🤖apk 📲
✔️ 7895aa7 #1 2023-04-18 12:38:18 ~7 min ios 📱ipa 📲
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 8491868 #2 2023-04-18 12:52:55 ~6 min tests 📄log
✔️ 8491868 #2 2023-04-18 12:53:01 ~6 min android-e2e 🤖apk 📲
✔️ 8491868 #2 2023-04-18 12:53:23 ~6 min android 🤖apk 📲
✔️ 8491868 #2 2023-04-18 12:55:11 ~8 min ios 📱ipa 📲
✔️ c300037 #3 2023-04-18 13:23:08 ~5 min android 🤖apk 📲
✔️ c300037 #3 2023-04-18 13:23:27 ~6 min android-e2e 🤖apk 📲
✔️ c300037 #3 2023-04-18 13:23:41 ~6 min tests 📄log
✔️ c300037 #3 2023-04-18 13:28:26 ~11 min ios 📱ipa 📲

@@ -43,7 +43,7 @@
[:f>
(fn []
(let [duration (or (rf/sub [:toasts/toast-cursor id :duration]) 3000)
on-dismissed #((or (rf/sub [:toasts/toast-cursor id :on-dismissed]) identity) id)
on-dismissed (or (rf/sub [:toasts/toast-cursor id :on-dismissed]) identity)
Copy link
Member Author

Choose a reason for hiding this comment

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

this is the fix

Copy link
Contributor

@ilmotta ilmotta left a comment

Choose a reason for hiding this comment

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

Good catch and fix @flexsurfer

@@ -80,7 +80,7 @@
(create-timer)))))]
;; create auto dismiss timer, clear timer when unmount or duration changed
(rn/use-effect (fn [] (create-timer) clear-timer) [duration])
(rn/use-unmount on-dismissed)
(rn/use-unmount #(on-dismissed id))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to pass the id here and create the anonymous function? It's questionable because the subscription [:toasts/toast-cursor id :on-dismissed] already returns a function that has access to the id value and the identity function doesn't care about any argument in this case.

I'm just wondering why it wouldn't work using just (rn/use-unmount on-dismissed).

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

It's just to handle situations where id and on-dismissed are both dynamically generated and hard or not elegant enough to pass the id to the on-dismissed fn.
It might be a premature optimization.

@flexsurfer flexsurfer merged commit 05b8dd5 into develop Apr 18, 2023
@flexsurfer flexsurfer deleted the bug/wrong-subs branch April 18, 2023 17:30
ibrkhalil pushed a commit that referenced this pull request Apr 20, 2023
alwx pushed a commit that referenced this pull request Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

subscriptions leak
5 participants