-
Notifications
You must be signed in to change notification settings - Fork 12
test: add test for async sessionStorageProvider #370
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
Conversation
test/node/session-provider-async.js
Outdated
| const TIMEOUT = 100; | ||
| const map = new Map(); | ||
| const sessionStorageProvider = { | ||
| set: (sessionId, session) => { |
There was a problem hiding this comment.
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.
lundibundi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
test/node/session-provider-async.js
Outdated
| const application = new jstp.Application(APP_NAME, interfaces); | ||
|
|
||
| const TIMEOUT = 100; | ||
| const map = new Map(); |
There was a problem hiding this comment.
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.
9c0e4d0 to
2b8efb7
Compare
PR-URL: #370 Reviewed-By: Denys Otrishko <shishugi@gmail.com>
|
Landed in 0b77237. |
PR-URL: #370 Reviewed-By: Denys Otrishko <shishugi@gmail.com>
No description provided.