← Back
Vercel
Vercel's Chat SDK adds concurrent message handling with configurable strategies

Concurrent Message Handling in Chat SDK

The Chat SDK now includes built-in support for managing message concurrency through the new concurrency option on the Chat class. This addresses a common challenge in conversational applications where users send multiple messages before the system finishes processing previous ones.

Available Strategies

Four concurrency strategies are now available to suit different use cases:

  • drop (default): Discards new incoming messages if a handler is still processing
  • queue: Processes the latest message after the current handler finishes, maintaining order
  • debounce: Waits for a pause in the conversation before processing only the final message
  • concurrent: Processes every message immediately without any locking mechanism

Configuration Options

When using the queue strategy, developers can fine-tune behavior with additional parameters:

  • maxQueueSize: Limit the number of messages that can be queued
  • onQueueFull: Specify what happens when the queue reaches capacity (e.g., drop-oldest)
  • queueEntryTtlMs: Set a time-to-live for queued messages to prevent stale processing

Getting Started

Developers can enable concurrent handling by passing the concurrency configuration when instantiating the Chat class. Full documentation and implementation examples are available in the Chat SDK docs.