Skip to content

Conversation

taranvohra
Copy link
Member

@taranvohra taranvohra commented Sep 25, 2025

When we receive a slack event for an Ask AI query it can sometimes take more than 30s for the AI API to respond. 30s is the timeout limit of waitUntil in cf workers

This PR changes the strategy where we queue an async task for the AI query so it's not subject to the 30s limit of waitUntil

Copy link

linear bot commented Sep 25, 2025

Copy link

changeset-bot bot commented Sep 25, 2025

🦋 Changeset detected

Latest commit: c7f21b1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@gitbook/integration-slack Patch
@gitbook/runtime Minor
@gitbook/integration-formspree Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

pkg-pr-new bot commented Sep 25, 2025

Open in StackBlitz

bun add https://pkg.pr.new/GitbookIO/integrations/@gitbook/api@1011

commit: c7f21b1

@taranvohra taranvohra marked this pull request as ready for review September 25, 2025 15:30
@taranvohra taranvohra requested a review from Copilot September 25, 2025 15:41
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the Slack integration's Ask AI query processing to use asynchronous integration tasks instead of blocking operations. The primary goal is to handle scenarios where AI API responses take longer than the 30-second timeout limit of Cloudflare Workers' waitUntil.

Key changes:

  • Splits the query processing into immediate acknowledgment and async task execution
  • Adds integration task queue infrastructure with signature verification
  • Refactors utility functions to support the new async flow

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
integrations/slack/src/utils.ts Adds crypto utilities and refactors installation API client methods
integrations/slack/src/types.ts Defines integration task types and interfaces for async processing
integrations/slack/src/router.ts Implements task endpoint with signature verification for processing queued tasks
integrations/slack/src/actions/queryAskAI.ts Refactors Ask AI processing to queue async tasks and handle them separately
integrations/slack/package.json Updates itty-router dependency to version 4.0.26

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@taranvohra taranvohra force-pushed the taran/rnd-7955-slack-integration-gitbook-bot-stops-responding-after-first branch from 0d7e91d to 02285b0 Compare September 26, 2025 12:36
@taranvohra taranvohra merged commit 75d605c into main Sep 26, 2025
13 checks passed
@taranvohra taranvohra deleted the taran/rnd-7955-slack-integration-gitbook-bot-stops-responding-after-first branch September 26, 2025 13:10
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.

2 participants