Skip to content
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

🐛 Fix FastAPI People GitHub Action: set HTTPX timeout for GraphQL query request #5222

Merged
merged 20 commits into from Sep 4, 2022

Conversation

iudeen
Copy link
Contributor

@iudeen iudeen commented Aug 2, 2022

Fixes an error that occurred in scheduled actions of FastAPI People.

I have tested using my token, and it works as expected. Results here (too big to paste 🥲)

Reason for the fix:
Since the query results are too big, httpx default timeout of 5 seconds is not enough, resulting in ReadTimeout exception.

Traceback (most recent call last):
  File "/app/main.py", line 427, in <module>
    settings=settings
  File "/app/main.py", line 309, in get_experts
    issue_edges = get_graphql_issue_edges(settings=settings, after=last_edge.cursor)
  File "/app/main.py", line 284, in get_graphql_issue_edges
    data = get_graphql_response(settings=settings, query=issues_query, after=after)
  File "/app/main.py", line 273, in get_graphql_response
    json={"query": query, "variables": variables, "operationName": "Q"},
  File "/usr/local/lib/python3.7/site-packages/httpx/_api.py", line 320, in post
    trust_env=trust_env,
  File "/usr/local/lib/python3.7/site-packages/httpx/_api.py", line 110, in request
    follow_redirects=follow_redirects,
  File "/usr/local/lib/python3.7/site-packages/httpx/_client.py", line 815, in request
    return self.send(request, auth=auth, follow_redirects=follow_redirects)
  File "/usr/local/lib/python3.7/site-packages/httpx/_client.py", line 906, in send
    history=[],
  File "/usr/local/lib/python3.7/site-packages/httpx/_client.py", line 933, in _send_handling_auth
    history=history,
  File "/usr/local/lib/python3.7/site-packages/httpx/_client.py", line 967, in _send_handling_redirects
    response = self._send_single_request(request)
  File "/usr/local/lib/python3.7/site-packages/httpx/_client.py", line 1003, in _send_single_request
    response = transport.handle_request(request)
  File "/usr/local/lib/python3.7/site-packages/httpx/_transports/default.py", line 218, in handle_request
    resp = self._pool.handle_request(req)
  File "/usr/local/lib/python3.7/contextlib.py", line 130, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/local/lib/python3.7/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ReadTimeout: The read operation timed out

This PR adds a configurable default timeout and read timeout. Even if its not set as environment variable, the httpx_read_time_out defaults to 30 seconds and httpx_default_time_out defaults to httpx default, which is 5 seconds.

@codecov
Copy link

codecov bot commented Aug 2, 2022

Codecov Report

Merging #5222 (3461db3) into master (0195bb5) will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##            master     #5222   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          539       539           
  Lines        13902     13902           
=========================================
  Hits         13902     13902           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 2, 2022

📝 Docs preview for commit 5e5352f at: https://62e93f5124c2231a962ef181--fastapi.netlify.app

@iudeen
Copy link
Contributor Author

iudeen commented Aug 2, 2022

Should I drive with an environment variable instead of hard-coding 30?

@github-actions
Copy link
Contributor

github-actions bot commented Aug 2, 2022

📝 Docs preview for commit 76cbeb1 at: https://62e943bddc072d1e10747d7a--fastapi.netlify.app

@iudeen
Copy link
Contributor Author

iudeen commented Aug 3, 2022

@tiangolo this might be trivial. Stumbled upon actions tab and found that this action is failing for last 2 months, and this might fix it.

Also there might be a need to configure a env variable (optional, defaults to 30).

@github-actions
Copy link
Contributor

github-actions bot commented Aug 8, 2022

📝 Docs preview for commit 9487385 at: https://62f0e65fac35f861ecd93ca7--fastapi.netlify.app

Copy link
Contributor Author

@iudeen iudeen left a comment

Choose a reason for hiding this comment

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

Hope this is okay! :)

@github-actions
Copy link
Contributor

📝 Docs preview for commit c6735f8 at: https://62fdbbf2362b7b55454f112a--fastapi.netlify.app

@iudeen iudeen changed the title fix: added timeout to avoid ReadTimeout Error. [GitHub-Actions]: added timeout to avoid ReadTimeout Error in “peoples” action Aug 18, 2022
@github-actions
Copy link
Contributor

📝 Docs preview for commit 45cab92 at: https://62fec0c48802d000a68820fe--fastapi.netlify.app

@github-actions
Copy link
Contributor

📝 Docs preview for commit feb10df at: https://6305e6e06d6fbc5a5e9b9fad--fastapi.netlify.app

@github-actions
Copy link
Contributor

📝 Docs preview for commit 8e8fe07 at: https://6308a074cf308e78b9e75037--fastapi.netlify.app

@github-actions
Copy link
Contributor

📝 Docs preview for commit 45c172b at: https://6308d96970db72283dcc5e59--fastapi.netlify.app

@github-actions
Copy link
Contributor

📝 Docs preview for commit e75dff0 at: https://6308e5cdfd6621375f0653de--fastapi.netlify.app

@iudeen iudeen marked this pull request as draft September 3, 2022 05:36
@github-actions
Copy link
Contributor

github-actions bot commented Sep 3, 2022

📝 Docs preview for commit 4d7bfbb at: https://6312e999e31c9631267850f8--fastapi.netlify.app

@github-actions
Copy link
Contributor

github-actions bot commented Sep 3, 2022

📝 Docs preview for commit 1ab76a1 at: https://6312f04e7f1ade5a2d6d8224--fastapi.netlify.app

@iudeen iudeen marked this pull request as ready for review September 3, 2022 06:16
@iudeen iudeen changed the title [GitHub-Actions]: added timeout to avoid ReadTimeout Error in “peoples” action Fix in GitHub-Actions: added timeout to avoid ReadTimeout Error in “peoples” action Sep 3, 2022
@iudeen
Copy link
Contributor Author

iudeen commented Sep 4, 2022

@tiangolo is this something you will be interested in? If not, we can close :)

@github-actions
Copy link
Contributor

github-actions bot commented Sep 4, 2022

📝 Docs preview for commit 39f5fbb at: https://63146c8b00ed394bc6d435d5--fastapi.netlify.app

@github-actions
Copy link
Contributor

github-actions bot commented Sep 4, 2022

📝 Docs preview for commit 92a1eab at: https://6314bb0567c58a7ae2aa7ce3--fastapi.netlify.app

@tiangolo
Copy link
Owner

tiangolo commented Sep 4, 2022

Nice, thank you @iudeen! 🙇

I updated it to simplify the code a bit. Thanks for your contribution! 🍰

@tiangolo tiangolo changed the title Fix in GitHub-Actions: added timeout to avoid ReadTimeout Error in “peoples” action 🐛 Fix FastAPI People GitHub Action: set HTTPX timeout for GraphQL query request Sep 4, 2022
@tiangolo tiangolo enabled auto-merge (squash) September 4, 2022 15:05
@tiangolo tiangolo merged commit 4cff206 into tiangolo:master Sep 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants