Menu

Workflow SDK now writes over WebSockets on Vercel - Vercel
📰

Workflow SDK now writes over WebSockets on Vercel - Vercel

Vercel News·Alex Langenfeld·6 days ago
#iBVgRNW5
#vercel#workflow#chunks#writes#websocket
Reading 0:00
15s threshold

The Workflow SDK now sends event writes and stream writes to Vercel Workflows over a WebSocket by default, replacing one HTTP request per write, or per write group for streams. No code change is needed beyond upgrading to [email protected] or later.

Once you deploy the upgrade, new runs use it. In-flight runs finish on the deployment they started on.

npm install workflow@latest

Existing streaming code works as is. A step that writes a burst of chunks, like AI tokens, sends them over the WebSocket once it opens:

import { getWritable } from "workflow" ;

async function streamChunks ( chunks : string [ ] ) {

"use step" ;

const writer = getWritable < string > ( ) . getWriter ( ) ;

for ( const chunk of chunks ) {

await writer . write ( chunk ) ;

}

writer .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.