Skip to content

[BUG] Error in store converter hangs store.get() calls indefinitely #660

Open
@jacobian2020

Description

@jacobian2020

Describe the bug
When store.get() is called to retrieve a value, it should throw or return value. It should not hang indefinitely.

To Reproduce
Steps to reproduce the behavior:
The following unit test will confirm the behavior.

class StoreTest {

    @Test
    fun error_in_store_converter_causes_call_to_never_return() {
        val store =
            StoreBuilder
                .from(
                    fetcher = Fetcher.of { key: Int -> "fetcher_${key}" },
                    sourceOfTruth = SourceOfTruth.of(
                        reader = { key ->
                            flow<String> {
                                emit("source_of_truth_${key}")
                            }
                        },
                        writer = { _: Int, _: String ->

                        }
                    ),
                    converter = object : Converter<String, String, String> {
                        override fun fromNetworkToLocal(network: String): String {
                            throw IllegalArgumentException()
                        }

                        override fun fromOutputToLocal(output: String): String {
                            return output
                        }
                    },
                ).validator(Validator.by { false }).disableCache().build()

        val key = 1
        val result = runBlocking { store.get(key = key) }
        //The following line is never reached
        Assert.assertEquals("source_of_truth_${key}",result)
    }
}

Expected behavior
Test should complete and not hang indefinitely.

Smartphone (please complete the following information):

  • Device: x86 workstation (NOT a smartphone)
  • OS: Linux
  • Store Version: 5.1.0-alpha02

Additional context
This error is logged in stdout. But it is never thrown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    🆕 Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions