-
Notifications
You must be signed in to change notification settings - Fork 166
feat: async session manager #4067
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
base: main
Are you sure you want to change the base?
Conversation
Bundles Sizes Evolution
🚀 CPU Performance
🧠 Memory Performance
|
|
dc49dab to
cf26f2b
Compare
7b107f7 to
6e0e1f7
Compare
| function check() { | ||
| try { | ||
| const result = callback() | ||
| if (result && typeof (result as any).then === 'function') { | ||
| ;(result as Promise<T>).then(handleResult, handleError) | ||
| } else { | ||
| handleResult(result as T) | ||
| } | ||
| } catch (error) { | ||
| handleError(error as Error) | ||
| } | ||
| } |
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.
suggestion: you can simplify all this as:
function check() {
Promise.resolve().then(callback).then(handleResult, handleError)
}And sometimes in the future:
function check() {
Promise.try(callback).then(handleResult, handleError)
}| beforeEach(async () => { | ||
| LOGS = makeLogsPublicApi(startLogs) | ||
| LOGS.init(DEFAULT_INIT_CONFIGURATION) | ||
| await waitFor(() => startLogs.calls.count() > 0) |
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.
question: not sure to understand why you put waitFor in many places. When I remove those waitFor, tests are still passing?
Also suggestion: use collectAsyncCalls instead of waitFor (it'll be more efficient)
await collectAsyncCalls(startLogs, 1)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.
It was super flaky for me. Most of the time, it varies between 3 or 25 tests failing. So I chose to add waitFor everywhere.
| // acquire lock | ||
| currentLock = createLock() | ||
| persistWithLock(currentStore.session) | ||
| safePersist(() => persistWithLock(currentStore.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.
question: Why do we need this change?
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.
I noticed that the session manager inits before the tryInit, so it outside of the monitor call.
Motivation
The Session Manager Revamp (SMR) will require our session manager to operate asynchronously and postpone the SDK initialization until the session is ready.
Changes
onReadycallback in session manager that propagates through all places using the start of the session.Test instructions
TBD
Checklist