-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Allow idleTimeout/lifespan larger than 32-bit signed integer. #79858
Conversation
*/ | ||
private startTimer(updater: (timeoutID: number) => void, callback: () => void, timeout: number) { | ||
// Max timeout is the largest possible 32-bit signed integer or 2,147,483,647 or 0x7fffffff. | ||
const maxTimeout = 0x7fffffff; |
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.
note: didn't want to create a dedicated top level const for this purely "technical" thing....
Pinging @elastic/kibana-security (Team:Security) |
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.
Tested locally with small and large timeout values. LGTM! 🎉
test(`stop works properly for large timeouts`, async () => { | ||
http.fetch.mockResolvedValue({ | ||
...defaultSessionInfo, | ||
idleTimeoutExpiration: now + 5_000_000_000, |
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.
TIL you can use underscores in JS numbers 😁 pretty cool
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.
Yeah, I like it as well. Unfortunately we cannot use it in a non-test code yet (at least something was complaining about that during the build) 🙁 Should probably be easy to tweak our build/transpilation pipeline though, I see it's Stage 4
proposal already.
In this PR we add a client-side
startTimer
function that allows us to workaround a maximum allowed JavaScript timeout (32-bit signed integer or 2,147,483,647 ms or 24.8 days). The main idea here is that in case of large timeout values this method recursively callssetTimeout
keeping track of current timeout ID so that it can be cleared at any time.Unblocks: #68885
Fixes: #22374
Release note: Kibana can now properly handle values for
xpack.security.session.idleTimeout
andxpack.security.session.lifespan
that are larger than ~24 days.