Skip to content

connectFactoryObservable: Object parameters will cause infinite loops #125

@SebKranz

Description

@SebKranz

Hey, thanks for the project. You saved me a lot of headaches.

The following code will lead to an infinite loop when used in a component:

export type ArticleQuery = {
	searchTerm?: string,
	author?: string
}

const [useArticleQuery] = bind((query: ArticleQuery) => searchForArticles$(query))

This is likely, because the NestedMap only expects an array of arguments and doesn't deeply compare objects.

I would suggest taking a look at the system that react-query uses for key generation. They sort the entries of an object before converting it to json. (See the function stableStringify)

Maybe it is also somehow possible to detect when a loop occurs and throw an error instead of potentially sending many requests to a server.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions