Skip to content

Conversation

sergeibbb
Copy link
Member

@sergeibbb sergeibbb commented Aug 27, 2024

Description

handleException and requestExceptionCount etc. We should stop calling our APIs in a session if there’s a problem and X attempts in a row fail.

Checklist

  • I have followed the guidelines in the Contributing document
  • My changes follow the coding style of this project
  • My changes build without any errors or warnings
  • My changes have been formatted and linted
  • My changes include any required corresponding changes to the documentation (including CHANGELOG.md and README.md)
  • My changes have been rebased and squashed to the minimal number (typically 1) of relevant commits
  • My changes have a descriptive commit message with a short title, including a Fixes $XXX - or Closes #XXX - prefix to auto-close the issue that your PR addresses

sergeibbb added a commit that referenced this pull request Aug 27, 2024
by setting up a fetching layer that is used by both DraftsService (code suggestions via S3) and ServerConnection (GK API)
GLVSC-625 #3494
sergeibbb added a commit that referenced this pull request Aug 27, 2024
@sergeibbb sergeibbb force-pushed the chore/GLVSC-625-handle-api-errors-and-frequency branch from 9ab6c88 to c873f7c Compare August 27, 2024 16:23
sergeibbb added a commit that referenced this pull request Aug 27, 2024
sergeibbb added a commit that referenced this pull request Aug 27, 2024
just track the count and stop when there are too many errors
GLVSC-625 #3494
@sergeibbb sergeibbb requested review from axosoft-ramint, d13 and sergiolms and removed request for d13 August 27, 2024 16:24
@axosoft-ramint axosoft-ramint self-assigned this Aug 27, 2024
options?: { token?: string; organizationId?: string },
): Promise<Response> {
if (this.requestsAreBlocked) {
throw new Error('Requests are blocked');
Copy link
Contributor

Choose a reason for hiding this comment

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

We're throwing an error now in places where we weren't before. Should we be catching/handling this from the callers? And if not, have we verified that it doesn't break anything?

Copy link
Member Author

Choose a reason for hiding this comment

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

fetchApi is private inside of SubscriptionService and in all 3 places where it's called all exceptions are caught now.

But, we probably can handle it differently from other types of exceptions. For example, when checkInAndValidateCore catches and exception it changes subscription status. Maybe we shouldn't do it for this type of error?

Copy link
Member Author

@sergeibbb sergeibbb Sep 10, 2024

Choose a reason for hiding this comment

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

@axosoft-ramint
Well, what I see is that it has started hitting debugger expressions that haven't been hit before. Here is an example on the picture, but probably, there are more such places. Should we do anything about it now or it can be postponed?

image

Copy link
Contributor

@axosoft-ramint axosoft-ramint Sep 10, 2024

Choose a reason for hiding this comment

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

That's probably fine? Before these changes, it would hit this anyway if the fetch threw an error, so really the only new error we're introducing that hits this debugger is from too many failed requests, in which case, we would probably want to hit this line and know about it anyway.

@eamodio
Copy link
Member

eamodio commented Aug 27, 2024

@sergeibbb At the high-level I'm confused by the need to have both ServerConnection (existing) and FetchingService (new), why did we need to introduce FetchingService? Why couldn't ServerConnection (or a holistic replacement of it) serve our needs here?

For example, the DraftsService now has a reference to both, and uses them for different usages that feels like it make things more complex.

@sergeibbb
Copy link
Member Author

@eamodio

At the high-level I'm confused by the need to have both ServerConnection (existing) and FetchingService (new), why did we need to introduce FetchingService? Why couldn't ServerConnection (or a holistic replacement of it) serve our needs here?

For example, the DraftsService now has a reference to both, and uses them for different usages that feels like it make things more complex.

Because DraftsService sends requests both to GK API and to S3. It seemed strange to block calls to S3 when GKDev is out.
So, Fetching service is responsible for making any types of requests to different services and the ServerConnection is responsible for making connection to the GK Dev server.

It was discussed here: https://gitkraken.atlassian.net/browse/GLVSC-625?focusedCommentId=123664

@eamodio
Copy link
Member

eamodio commented Aug 28, 2024

But those were already handled differently in ServerConnection, the "raw" fetch method allowed for more general fetching, and the other fetch versions covered more specific cases for the GK API.

Sure, having a "generic" fetch on ServerConnection was always a bit odd, since that class' intent was connecting to our backend, but today that was conceptually still true because the S3 calls are all in service of taking to our backend (just an implementation detail). At the same time, we could move that more generic fetch into a pure utility function.

I'm also unsure of why we wouldn't encapsulate the connection/exception tracking within ServerConnection rather than have it in SubscriptionService. It feels like implementation details are leaking there. And if we change that, do we still need the Retriever?

@sergeibbb
Copy link
Member Author

@eamodio

that more generic fetch into a pure utility function.

Could be. But it needs a link to the container to build the userAgent value.

Anyway, I can join those two classes back and keep that little oddness.

why we wouldn't encapsulate the connection/exception tracking within ServerConnection rather than have it in SubscriptionService.

because it's going to be reset with a new session, but the session is controlled by SubscriptionService. Anyway, it can be moved back to the ServerConnection.

@sergeibbb
Copy link
Member Author

sergeibbb commented Aug 28, 2024

@eamodio

And if we change that, do we still need the Retriever?

We only don't need the retriever, if we stop handling the request error inside of the generic fetch and move the handling to the fetchApi, that is GK specific. That is OK while we don't expect outage or rate-limit problems from S3.

sergeibbb added a commit that referenced this pull request Aug 28, 2024
sergeibbb added a commit that referenced this pull request Aug 28, 2024
sergeibbb added a commit that referenced this pull request Aug 28, 2024
just track the count and stop when there are too many errors
GLVSC-625 #3494
@sergeibbb sergeibbb force-pushed the chore/GLVSC-625-handle-api-errors-and-frequency branch from 6661f2e to fdb923e Compare August 28, 2024 13:39
sergeibbb added a commit that referenced this pull request Aug 28, 2024
@sergeibbb sergeibbb marked this pull request as draft August 28, 2024 16:09
sergeibbb added a commit that referenced this pull request Aug 28, 2024
sergeibbb added a commit that referenced this pull request Aug 28, 2024
sergeibbb added a commit that referenced this pull request Aug 28, 2024
@sergeibbb sergeibbb force-pushed the chore/GLVSC-625-handle-api-errors-and-frequency branch from 827e97a to daf9e3b Compare August 28, 2024 17:05
sergeibbb added a commit that referenced this pull request Aug 29, 2024
sergeibbb added a commit that referenced this pull request Aug 30, 2024
by setting up a fetching layer that is used by both DraftsService (code suggestions via S3) and ServerConnection (GK API)
GLVSC-625 #3494
sergeibbb added a commit that referenced this pull request Sep 9, 2024
@sergeibbb sergeibbb force-pushed the chore/GLVSC-625-handle-api-errors-and-frequency branch from ea6ba12 to eabb282 Compare September 9, 2024 11:56
@sergeibbb sergeibbb force-pushed the chore/GLVSC-625-handle-api-errors-and-frequency branch from eabb282 to 83b7fcc Compare September 9, 2024 12:31
@sergeibbb sergeibbb changed the title Add fallback/cutoff to our backend calls similar to how we handle GitHub queries (GLVSC-625) Add fallback/cutoff to our backend calls similar to how we handle GitHub queries #3519 Sep 9, 2024
sergeibbb added a commit that referenced this pull request Sep 9, 2024
sergeibbb added a commit that referenced this pull request Sep 9, 2024
@sergeibbb sergeibbb force-pushed the chore/GLVSC-625-handle-api-errors-and-frequency branch from 83b7fcc to 0ac26c4 Compare September 9, 2024 16:24
sergeibbb added a commit that referenced this pull request Sep 9, 2024
@axosoft-ramint axosoft-ramint self-requested a review September 9, 2024 18:52
@sergeibbb sergeibbb force-pushed the chore/GLVSC-625-handle-api-errors-and-frequency branch from 49083ab to 0ff30e2 Compare September 10, 2024 12:43
@sergeibbb sergeibbb marked this pull request as ready for review September 10, 2024 13:25
Copy link
Contributor

@axosoft-ramint axosoft-ramint left a comment

Choose a reason for hiding this comment

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

Latest version looks good. I didn't really have time to exhaust all the possibilities but what I did simulate, it handles well. Thanks for working on it!

Let's wait to merge this until after our patch release, because it's targeting main and I would like this to sit in the prerelease for longer before we release it.

@sergeibbb
Copy link
Member Author

Hi @axosoft-ramint
A release has happened. Can I merge?

@axosoft-ramint axosoft-ramint merged commit 157a902 into main Sep 13, 2024
2 checks passed
@axosoft-ramint axosoft-ramint deleted the chore/GLVSC-625-handle-api-errors-and-frequency branch September 13, 2024 15:11
@axosoft-ramint
Copy link
Contributor

A release has happened. Can I merge?

@sergeibbb Thanks for the reminder! Merged it.

@d13 d13 added the pending-release Resolved but not yet released to the stable edition label Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release Resolved but not yet released to the stable edition

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add fallback/cutoff to our backend calls similar to how we handle GitHub queries

4 participants