slackapi / slackapi/bolt-python

Lazy listeners do not work with Chalice local testing server

Open
#490 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:adapter enhancement good first issue
Dominant language
Python
Stars
1.3k
Forks
288
Avg merge
1d 8h
Merged PRs (30d)
10

Description

I want to perform operations when a member has joined a channel which takes more than 5 seconds, but I'm getting BrokenPipeError: [Errno 32] Broken pipe.

The minimal step to reproduce the same has been shown below while using the lazy listener it waits for 10 seconds before responding back.

Reproducible in:
from chalice import Chalice, Response
from slack_bolt import App
from slack_bolt.adapter.aws_lambda.chalice_handler import ChaliceSlackRequestHandler

bolt_app = App(process_before_response=True)
app = Chalice(app_name='chalice_app_name')
slack_handler = ChaliceSlackRequestHandler(app=bolt_app, chalice=app)


@bolt_app.event("message")
def handle_message_events(body, logger):
    logger.info(body['event']['text'])


def respond_to_slack_within_3_seconds(ack):
    ack("Accepted!")


def say_it(say):
    time.sleep(10)
    say("Done!")


bolt_app.event("member_joined_channel")(
    ack=respond_to_slack_within_3_seconds, lazy=[say_it]
)


@app.route(
    "/slack/events",
    methods=["POST"],
    content_types=["application/x-www-form-urlencoded", "application/json"],
)
def events() -> Response:
    return slack_handler.handle(app.current_request)

The slack_bolt version

slack-bolt==1.9.1
slack-sdk==3.11.1

Python runtime version

Python 3.6.15

OS info

Ubuntu 20.04.3 LTS

Steps to reproduce:
  1. While handling of any Slack event (e.g. handle_member_joined event)
  2. Use lazy listener and wait for more than 3 seconds before responding back to Slack
Expected result:

Since the event is acknowledging the Slack within 3 seconds irrespective of the lazy listener function time, it should have processed the same.

Actual result:

s1
s2

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the ChaliceSlackRequestHandler entry point and reproduce the member_joined_channel event with process_before_response enabled and a lazy listener that sleeps for 10 seconds. Check the local testing server behavior around the /slack/events response and confirm that the lazy listener completes without BrokenPipeError after the acknowledgement is sent.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.