LoginSignup
2
0

CircleCI + LocalstackでError in ASGI Framework

Last updated at Posted at 2023-08-11

事象

  • localstack:2.2.1.devをCircleCIで動かしたら以下のエラーが発生した。

jobの実行ログ

LocalStack version: 2.2.1.dev
LocalStack build date: 2023-08-08
LocalStack build git hash: f1ac9eb4

2023-08-08T09:44:08.368  WARN --- [  MainThread] localstack.deprecations    : DEFAULT_REGION is deprecated (since 0.12.7) and will be removed in upcoming releases of LocalStack! LocalStack now has full multi-region support. Please remove this environment variable.
2023-08-08T09:44:08.368  WARN --- [  MainThread] localstack.deprecations    : DATA_DIR is deprecated (since 1.0.0) and will be removed in upcoming releases of LocalStack! Please use PERSISTENCE instead. The state will be stored in your LocalStack volume in the state/ directory.
2023-08-08T09:44:08.522  INFO --- [-functhread3] hypercorn.error            : Running on https://0.0.0.0:4566 (CTRL + C to quit)
2023-08-08T09:44:08.522  INFO --- [-functhread3] hypercorn.error            : Running on https://0.0.0.0:4566 (CTRL + C to quit)
Ready.
2023-08-08T09:44:20.056 ERROR --- [-functhread3] hypercorn.error            : Error in ASGI Framework
Traceback (most recent call last):
  File "/opt/code/localstack/.venv/lib/python3.10/site-packages/hypercorn/asyncio/task_group.py", line 23, in _handle
    await app(scope, receive, send, sync_spawn, call_soon)
  File "/opt/code/localstack/.venv/lib/python3.10/site-packages/hypercorn/app_wrappers.py", line 33, in __call__
    await self.app(scope, receive, send)
  File "/opt/code/localstack/localstack/aws/serving/asgi.py", line 67, in __call__
    return await self.wsgi(scope, receive, send)
  File "/opt/code/localstack/localstack/http/asgi.py", line 319, in __call__
    return await self.handle_http(scope, receive, send)
  File "/opt/code/localstack/localstack/http/asgi.py", line 388, in handle_http
    await response.close()
  File "/opt/code/localstack/localstack/http/asgi.py", line 269, in close
    await self.send({"type": "http.response.body", "body": b"", "more_body": False})
  File "/opt/code/localstack/.venv/lib/python3.10/site-packages/hypercorn/protocol/http_stream.py", line 188, in app_send
    await self.send(EndBody(stream_id=self.stream_id))
  File "/opt/code/localstack/.venv/lib/python3.10/site-packages/hypercorn/protocol/h11.py", line 138, in stream_send
    await self._send_h11_event(h11.EndOfMessage())
  File "/opt/code/localstack/.venv/lib/python3.10/site-packages/hypercorn/protocol/h11.py", line 240, in _send_h11_event
    data = self.connection.send(event)
  File "/opt/code/localstack/.venv/lib/python3.10/site-packages/h11/_connection.py", line 512, in send
    data_list = self.send_with_data_passthrough(event)
  File "/opt/code/localstack/.venv/lib/python3.10/site-packages/h11/_connection.py", line 545, in send_with_data_passthrough
    writer(event, data_list.append)
  File "/opt/code/localstack/.venv/lib/python3.10/site-packages/h11/_writers.py", line 67, in __call__
    self.send_eom(event.headers, write)
  File "/opt/code/localstack/.venv/lib/python3.10/site-packages/h11/_writers.py", line 96, in send_eom
    raise LocalProtocolError("Too little data for declared Content-Length")
h11._util.LocalProtocolError: Too little data for declared Content-Length
2023-08-08T09:44:20.056 ERROR --- [-functhread3] hypercorn.error            : Error in ASGI Framework
Traceback (most recent call last):
  File "/opt/code/localstack/.venv/lib/python3.10/site-packages/hypercorn/asyncio/task_group.py", line 23, in _handle
    await app(scope, receive, send, sync_spawn, call_soon)
  File "/opt/code/localstack/.venv/lib/python3.10/site-packages/hypercorn/app_wrappers.py", line 33, in __call__
    await self.app(scope, receive, send)
  File "/opt/code/localstack/localstack/aws/serving/asgi.py", line 67, in __call__
    return await self.wsgi(scope, receive, send)
  File "/opt/code/localstack/localstack/http/asgi.py", line 319, in __call__
    return await self.handle_http(scope, receive, send)
  File "/opt/code/localstack/localstack/http/asgi.py", line 388, in handle_http
    await response.close()
  File "/opt/code/localstack/localstack/http/asgi.py", line 269, in close
    await self.send({"type": "http.response.body", "body": b"", "more_body": False})
  File "/opt/code/localstack/.venv/lib/python3.10/site-packages/hypercorn/protocol/http_stream.py", line 188, in app_send
    await self.send(EndBody(stream_id=self.stream_id))
  File "/opt/code/localstack/.venv/lib/python3.10/site-packages/hypercorn/protocol/h11.py", line 138, in stream_send
    await self._send_h11_event(h11.EndOfMessage())
  File "/opt/code/localstack/.venv/lib/python3.10/site-packages/hypercorn/protocol/h11.py", line 240, in _send_h11_event
    data = self.connection.send(event)
  File "/opt/code/localstack/.venv/lib/python3.10/site-packages/h11/_connection.py", line 512, in send
    data_list = self.send_with_data_passthrough(event)
  File "/opt/code/localstack/.venv/lib/python3.10/site-packages/h11/_connection.py", line 545, in send_with_data_passthrough
    writer(event, data_list.append)
  File "/opt/code/localstack/.venv/lib/python3.10/site-packages/h11/_writers.py", line 67, in __call__
    self.send_eom(event.headers, write)
  File "/opt/code/localstack/.venv/lib/python3.10/site-packages/h11/_writers.py", line 96, in send_eom
    raise LocalProtocolError("Too little data for declared Content-Length")
h11._util.LocalProtocolError: Too little data for declared Content-Length


Build was canceled

エラー発生時のCircleCI側の設定

jobs:
  check_app:
    docker:
      - image: localstack/localstack:latest
        environment:
          SERVICES: dynamodb
          DEFAULT_REGION: ap-northeast-1
          DATA_DIR: /tmp/localstack/data
          ENDPOINT_URL: http://localhost:4566

対応

  • CircleCI側の設定にGATEWAY_LISTEN: 0.0.0.0:4566を追加した

CircleCI側の設定

jobs:
  check_app:
    docker:
      - image: localstack/localstack:latest
        environment:
          SERVICES: dynamodb
          DEFAULT_REGION: ap-northeast-1
          DATA_DIR: /tmp/localstack/data
          ENDPOINT_URL: http://localhost:4566
          GATEWAY_LISTEN: 0.0.0.0:4566
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0