-
Notifications
You must be signed in to change notification settings - Fork 141
[POC] Browser Workflows - Client-Side Durable Task Execution #480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
|
@alex-holovach is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
This is an early experiment, needs a lot of refactoring before proper review. Just wanted to share the idea and get some thoughts on whether client-side workflows via Web Workers makes sense. cc @pranaygp |
|
Pretty cool! I'm curious, how do you (plan on) addressing the determinism features that the VM provides when executing the workflow function? i.e. seeding |
Great question. I was wondering do we really need determinism in client side workflows? Current implementation uses checkpoint-based resumption (steps check DB for cached results) rather than event replay |
|
haven’t looked at code yet, just your description, but I do think we need determinism in workflow. ideally workflows are just portable and the world can swap underneath. event replay is also gonna matter for more features like versioning. checkpoint could be an optimization on top of event replay to allow us to skip event replay when a checkpoint is available. also open sockets wouldn’t cleanly retain across checkpoints if you allow the workflow context to “run anything” |
|
yeah that makes a lot of sense, i'll explore some options how to make it deterministic |
|
Super cool! I have been hacking on something similar as well. But, I have a slightly different implementation.
I will share my setup soon. |
|
Also, I had the exact thought process - using the browser world with WebLLM to build purely client side workflow builders. You can also take it one step further by storing the application layer metadata in indexDB persistence |
I was curious about how workflows could be used on the client side and decided to explore a Workers-based implementation that allows running workflows as durable, long-running tasks entirely in the browser.
As a proof of concept, I built an AI chat that runs completely locally using WebLLM - no backend required. The LLM inference runs in a Web Worker with the same
'use workflow'syntax we use on the server.local-chat-demo.mp4
How It Works
Key Features
'use workflow'directive just like server-side workflowsExample
How Compilation Works
The SWC plugin detects
'use workflow'in files matching the browser workflow pattern and transforms the code:Source (what you write):
Client bundle (main thread):
Worker bundle (Web Worker):