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

The function doesn't consider errors other than aiohttp.ClientResponseError #36

Open
tanaka-takayoshi opened this issue Mar 15, 2021 · 0 comments

Comments

@tanaka-takayoshi
Copy link

When HTTP POST request causes errors other than aiohttp.ClientResponseError, such as aiohttp.TimeOutError, the function doesn't retry and outputs the following error trace and Log entry sent message.

[ERROR] TimeoutError
Traceback (most recent call last):
  File "/var/task/function.py", line 510, in lambda_handler
    asyncio.run(_send_log_entry(log_entry, context))
  File "/var/lang/lib/python3.8/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/var/lang/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/var/task/function.py", line 222, in _send_log_entry
    return await asyncio.gather(*requests)
  File "/var/task/function.py", line 228, in _send_payload
    status, url = await http_post(
  File "/var/task/function.py", line 135, in http_post
    resp = await session.post(url, data=data, headers=headers)
  File "/var/task/aiohttp/client.py", line 466, in _request
    await resp.start(conn)
  File "/var/task/aiohttp/client_reqrep.py", line 803, in start
    self._continue = None
  File "/var/task/aiohttp/helpers.py", line 603, in __exit__
    raise asyncio.TimeoutError from None

Here is the whole log for this invocation. It looks the request succeeded for the log endpoint but failed for the infra endpoint.

START RequestId: ***(masked)*** Version: $LATEST
Log entry sent. Response code: 202. url: https://log-api.newrelic.com/log/v1
[ERROR] TimeoutError
END RequestId: ***(masked)***
REPORT RequestId: ***(masked)***	Duration: 3821.20 ms	Billed Duration: 3822 ms	Memory Size: 128 MB	Max Memory Used: 77 MB	

When session.post raises an error such as aiohttp.TimeOutError, except block doesn't handle this error. It means retry logic doesn't work.

The http_post method raises an error and this error isn't handled anywhere and goes to out of the function. It means lambda invocation fails and the function will be retried if the retry is enabled.

Could you add more except blocks for such errors as TimeOutError?

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

No branches or pull requests

1 participant