-
Notifications
You must be signed in to change notification settings - Fork 195
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
frontend: fix repeatStreamFunc
for list
requests
#1988
frontend: fix repeatStreamFunc
for list
requests
#1988
Conversation
1dd4837
to
4252e9e
Compare
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.
Thanks @msuret . This whole file is a hack, and we only recently added tests enough to be confident in changing it.
I think a more proper way of fixing this issue is to just pass the list arguments as is, to the functions that repeatStreamFunc calls. The only reason why we special case the errCb is because we need to use it in repeatStreamFunc, so we should have this arg separate, even if repeated in the list of args. This way we don't have to keep guessing indexes for function calls. Not sure if my idea is clear. WDYT @msuret ?
@skoeva , can you add a test for these functions?
@joaquimrocha I am not sure to understand what you mean by "have this arg separate". Is it something like Other solutions I can see (But they require more changes and thus are more risky):
|
`errCb` parameter is the 3rd argument of `get` function returned by `singleApiFactory`, whereas it's only the 2nd argument of `list`. This causes `repeatStreamFunc` to misbehave for `list` calls because the error callback index is hardcoded to `2`. Signed-off-by: msuret <11944422+msuret@users.noreply.github.com>
4252e9e
to
ae9d094
Compare
What I meant was simpler: async function repeatStreamFunc(
apiEndpoints: ApiFactoryReturn[],
funcName: keyof ApiFactoryReturn,
errCb: StreamErrCb,
...args: any[]
) Since the problem here is that we are passing the async function repeatStreamFunc(
apiEndpoints: ApiFactoryReturn[],
errCb: StreamErrCb,
funcName: keyof ApiFactoryReturn,
...args: any[]
) And inside the repeatStreamFunc, we call Since repeatStreamFunc is internal, it's totally fine to do this IMO. WDYT? |
+1 to the earlier comment, this file is due for a refactor and the test suite was only added recently. I agree with treating errCb independently as a potential approach, this avoids the guess work in getting its index. re: testing for |
@joaquimrocha I'm not sure that would work, from my understanding |
Ah! You are 100% correct. I had overlooked that part. Sorry. I will merge your PR as a fix for what we have, till we have a proper fix. Thank you! |
errCb
parameter is the 3rd argument ofget
function returned bysingleApiFactory
, whereas it's only the 2nd argument oflist
. This causesrepeatStreamFunc
to misbehave forlist
calls because the error callback index is hard-coded to2
.In my case I couldn't list custom resources with deprecated API versions.