Skip to content

Conversation

@fabriziodemaria
Copy link
Contributor

This PR

setContextAndWait shouldn't hang if the Provider fails the initalization phase for some reason.

Related Issues

N/A

Follow-up Tasks

Similar logic will need to be added to setEvaluationContext

How to test

Added unit tests

Signed-off-by: Fabrizio Demaria <fdema@spotify.com>
@fabriziodemaria fabriziodemaria force-pushed the wait-on-provider-error branch 4 times, most recently from edd81d4 to 3f12d8d Compare January 8, 2024 15:32
try {
provider.initialize(context)
} catch (e: Throwable) {
// This should never happen
Copy link
Member

Choose a reason for hiding this comment

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

Can we rephrase this to

This is not allowed to happen.

and maybe reference the spec?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think there is anything about this in the Spec. It's this specific implementation that expects the Provider to never throw and rather reads ProviderError events from the Provider.
The Java SDK, for example, works in the opposite way and expects the Provider to throw in case of errors

@fabriziodemaria fabriziodemaria marked this pull request as ready for review January 8, 2024 16:09
Signed-off-by: Fabrizio Demaria <fdema@spotify.com>
Signed-off-by: Fabrizio Demaria <fdema@spotify.com>
Signed-off-by: Fabrizio Demaria <fdema@spotify.com>
private var eventHandler = EventHandler(dispatcher)
override fun initialize(initialContext: EvaluationContext?) {
CoroutineScope(dispatcher).launch {
delay(10000)
Copy link
Member

Choose a reason for hiding this comment

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

nice!

@fabriziodemaria fabriziodemaria merged commit 1d4c24f into main Jan 9, 2024
@fabriziodemaria fabriziodemaria deleted the wait-on-provider-error branch January 9, 2024 09:08
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.

3 participants