Skip to content

Commit 927c427

Browse files
committed
client: Create a new HTTP session for each request
The globally shared connection resets after some time. When it's reset, the web worker will optimistically try to use it anyway, and fail with a connection error. WIth many web workers running behind a load balancer, this means that a huge portion of login requests would randomly land on a broken session and it was common for people to need to retry 3-4 times until their login attempt finally worked. You can see here how within the sentry project's own code, sessions are created on demand instead of being shared globally: https://github.com/getsentry/sentry/blob/27cc0fed47732dec907668a4529ca39bb384bf5a/src/sentry/http.py#L271
1 parent 81f6838 commit 927c427

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

sentry_auth_gitlab/client.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@ def __init__(self, message='', status=None):
1414

1515

1616
class GitLabClient(object):
17-
http = http.build_session()
18-
1917
def _request(self, path, access_token):
18+
session = http.build_session()
2019
headers = {'Authorization': 'Bearer {0}'.format(access_token)}
2120
url = '{0}/{1}'.format(API_BASE_URL, path.lstrip('/'))
2221

2322
try:
24-
req = self.http.get(url, headers=headers)
23+
req = session.get(url, headers=headers)
2524
except RequestException as e:
2625
raise GitLabApiError(unicode(e), status=e.status_code)
2726
return json.loads(req.content)

0 commit comments

Comments
 (0)