Skip to content

Conversation

@nechaido
Copy link
Member

No description provided.

const TIMEOUT = 100;
const map = new Map();
const sessionStorageProvider = {
set: (sessionId, session) => {
Copy link
Member

@lundibundi lundibundi Aug 17, 2018

Choose a reason for hiding this comment

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

Now that I've seen this, I thought about this async set. Ain't there a race condition between sessionStorageProvider.set and user reconnect. So if server uses async sessionStorageProvider and user reconnects too fast he may actually not get a session or he will get an outdated (because the session wasn't saved yet) session, wdyt @nechaido @belochub ?
One possible solution may be adding a callback argument to set and only this._clientsBySessionId.delete(connection.session.id); in the server if we know that it was stored (after callback call).

Also, I assume this race condition is a reason behind https://github.com/metarhia/jstp/pull/370/files#diff-b51f83d123e11290f6de4c2ee483762cR71 ? On a second thought, you need that to test the sessionProvider itself and not session caching. Though point still stands.

Edit: not related to the PR, just smth I thought about.

Copy link
Member

@lundibundi lundibundi left a comment

Choose a reason for hiding this comment

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

LGTM.

const application = new jstp.Application(APP_NAME, interfaces);

const TIMEOUT = 100;
const map = new Map();
Copy link
Member

Choose a reason for hiding this comment

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

Put map inside sessionStorageProvider and use function/this? Just a nit.

@nechaido nechaido force-pushed the session-provider-async branch from 9c0e4d0 to 2b8efb7 Compare August 21, 2018 09:51
nechaido added a commit that referenced this pull request Aug 21, 2018
PR-URL: #370
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
@nechaido
Copy link
Member Author

Landed in 0b77237.

@nechaido nechaido closed this Aug 21, 2018
@nechaido nechaido deleted the session-provider-async branch August 21, 2018 10:39
@belochub belochub added the test label Aug 30, 2018
belochub pushed a commit that referenced this pull request Aug 30, 2018
PR-URL: #370
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
@belochub belochub mentioned this pull request Aug 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants