Skip to content

[Issue #390] Fix “Completion handler can get overwritten for longpoll sessions"#391

Merged
jaquish merged 2 commits intomasterfrom
fix-id
Dec 15, 2025
Merged

[Issue #390] Fix “Completion handler can get overwritten for longpoll sessions"#391
jaquish merged 2 commits intomasterfrom
fix-id

Conversation

@jaquish
Copy link
Contributor

@jaquish jaquish commented Dec 11, 2025

We store data related to each URLSession in a “SessionData” object. To map from the session to the data, we either use the background id in the session config or assume that it is the foreground session.

However, there are actually 2 foreground sessions, one for longpoll routes. We used the same session data for both, which could result in bugs like completion handlers for tasks being overwritten.

Add a sessionDescription to disambiguate the sessions.

… sessions”

We store data related to each URLSession in a “SessionData” object. To map from the session to the data, we either use the background id in the session config or assume that it is the foreground session.

However, there are actually *2* foreground sessions, one for longpoll routes. We used the same session data for both, which could result in bugs like completion handlers for tasks being overwritten.

Add a sessionDescription to disambiguate the sessions.
@jaquish jaquish changed the title [Issue #390] Fix “Completion handler can get overwritten for longpoll… [Issue #390] Fix “Completion handler can get overwritten for longpoll sessions" Dec 11, 2025
@jaquish jaquish requested a review from jboulter11 December 12, 2025 18:11

- (NSString *)sessionIdWithSession:(NSURLSession *)session {
return session.configuration.identifier ?: kDBSDKForegroundSessionId;
return session.configuration.identifier ?: session.sessionDescription ?: kDBSDKForegroundSessionId;

Choose a reason for hiding this comment

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

Don't we need to concatenate something here? Or is that concat done later?

Copy link
Contributor Author

@jaquish jaquish Dec 12, 2025

Choose a reason for hiding this comment

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

SessionId maps to SessionData, and all session-scoped data gets stored on it. The issue was the regular foreground session and the longpoll one were getting the same sessionId. Tasks are stored on the sessiondata and looked up by their id. Example here

Choose a reason for hiding this comment

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

Ah okay I understand now. Thank you!

@jaquish jaquish merged commit a7be639 into master Dec 15, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants