Skip to content

AWS Lambda randomly fails after integration via the layer. #4311

Closed

Description

@myktailot-sangoma

Environment

SaaS (https://sentry.io/)

Steps to Reproduce

AWS Lambda randomly fails after integration via the layer with an exception "('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))"

[ERROR] 2025-04-15T10:45:37.022Z 841d023c-0790-5a8e-a74c-62443d62d4d9 Internal error in sentry_sdk
Traceback (most recent call last):
File "/opt/python/urllib3/connectionpool.py", line 716, in urlopen
httplib_response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "/opt/python/urllib3/connectionpool.py", line 468, in _make_request
six.raise_from(e, None)
File "", line 3, in raise_from
File "/opt/python/urllib3/connectionpool.py", line 463, in _make_request
httplib_response = conn.getresponse()
^^^^^^^^^^^^^^^^^^
File "/opt/python/sentry_sdk/integrations/stdlib.py", line 128, in getresponse
return real_getresponse(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/lang/lib/python3.12/http/client.py", line 1428, in getresponse
response.begin()
File "/var/lang/lib/python3.12/http/client.py", line 331, in begin
version, status, reason = self._read_status()
^^^^^^^^^^^^^^^^^^^
File "/var/lang/lib/python3.12/http/client.py", line 300, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/python/sentry_sdk/transport.py", line 563, in send_envelope_wrapper
self._send_envelope(envelope)
File "/opt/python/sentry_sdk/transport.py", line 497, in _send_envelope
self._send_request(
File "/opt/python/sentry_sdk/transport.py", line 349, in _send_request
response = self._request(
^^^^^^^^^^^^^^
File "/opt/python/sentry_sdk/transport.py", line 713, in _request
return self._pool.request(
^^^^^^^^^^^^^^^^^^^
File "/opt/python/urllib3/request.py", line 81, in request
return self.request_encode_body(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/python/urllib3/request.py", line 173, in request_encode_body
return self.urlopen(method, url, **extra_kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/python/urllib3/poolmanager.py", line 376, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/python/urllib3/connectionpool.py", line 802, in urlopen
retries = retries.increment(
^^^^^^^^^^^^^^^^^^
File "/opt/python/urllib3/util/retry.py", line 552, in increment
raise six.reraise(type(error), error, _stacktrace)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/python/urllib3/packages/six.py", line 769, in reraise
raise value.with_traceback(tb)
File "/opt/python/urllib3/connectionpool.py", line 716, in urlopen
httplib_response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "/opt/python/urllib3/connectionpool.py", line 468, in _make_request
six.raise_from(e, None)
File "", line 3, in raise_from
File "/opt/python/urllib3/connectionpool.py", line 463, in _make_request
httplib_response = conn.getresponse()
^^^^^^^^^^^^^^^^^^
File "/opt/python/sentry_sdk/integrations/stdlib.py", line 128, in getresponse
return real_getresponse(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/lang/lib/python3.12/http/client.py", line 1428, in getresponse
response.begin()
File "/var/lang/lib/python3.12/http/client.py", line 331, in begin
version, status, reason = self._read_status()
^^^^^^^^^^^^^^^^^^^
File "/var/lang/lib/python3.12/http/client.py", line 300, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

Expected Result

random fails

Actual Result

urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

Product Area

APIs

Link

No response

DSN

o384411

Version

No response

Activity

  1. getsantry commented on Apr 15, 2025

    @getsantry

    Assigning to @getsentry/support for routing ⏲️

  2. moved this to Waiting for: Support in GitHub Issues with 👀 3on Apr 15, 2025
  3. moved this from Waiting for: Support to Waiting for: Product Owner in GitHub Issues with 👀 3on Apr 16, 2025
  4. antonpirker commented on Apr 17, 2025

    @antonpirker
    Contributor

    Hey @myktailot-samgoma thanks for writing in.

    From the stack trace it seems that there is a problem when sending data to Sentry.
    Can you tell me if this is a long running function? If yes, then the keep_alive option may help.

    Do you get some data into Sentry? (I just want to make sure that the function can establish a HTTP connection to the Sentry server at all) Maybe it is a network problem between your function and Sentry?

  5. moved this from Waiting for: Product Owner to Waiting for: Community in GitHub Issues with 👀 3on Apr 17, 2025
  6. myktailot-sangoma commented on Apr 17, 2025

    @myktailot-sangoma
    Author

    We’re employing AWS Lambda Layer integration to keep our Lambda function code untouched.
    https://docs.sentry.io/platforms/python/integrations/aws-lambda/manual-layer/

    How I can add keep_alive using env variable?

  7. moved this from Waiting for: Community to Waiting for: Product Owner in GitHub Issues with 👀 3on Apr 17, 2025
  8. antonpirker commented on Apr 17, 2025

    @antonpirker
    Contributor

    Unfortunately there is no env var for keep_alive… I am afraid to have all the configuration power you need to manually add the SDK to your function: https://docs.sentry.io/platforms/python/integrations/aws-lambda/manual-instrumentation/

  9. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Apr 17, 2025
  10. szokeasaurusrex commented on May 5, 2025

    @szokeasaurusrex
    Member

    Hey @myktailot-samgoma – we are planning to add an environment variable for keep_alive. We will track the work for this in #4354, so I will close this issue for now.

    In the meantime, you can workaround the problem using @antonpirker's suggestion of manually adding the Python SDK to your Lambda function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions