NextJS
Deploying a Cascaide application built on Next.js is the same as deploying any other Next.js app. Check out https://nextjs.org/docs/app/getting-started/deploying .
The only thing to be mindful of is the WorkflowHandlerConfig.
import { WorkflowHandlerConfig } from '@cascaide-ts/server-next'
import { PostgresPersistor } from '@cascaide-ts/postgres-js';
import { sql } from '@/lib/connection';
import { serverWorkflowGraph } from './graph';
const workflowPersistor = new PostgresPersistor(sql);
const MAX_EXECUTION_TIME = 300000;
const SAFE_BUFFER = 10000;
export const serverWorkflowConfig: WorkflowHandlerConfig = {
workflowGraph: serverWorkflowGraph,
persistor: workflowPersistor,
maxExecutionTime: MAX_EXECUTION_TIME,
safeBuffer: SAFE_BUFFER
}| Config | Type | Description |
|---|---|---|
maxExecutionTime | number (ms) | Should match your serverless function’s timeout limit. Vercel Fluid Compute provides 300 seconds (300000 ms). |
safeBuffer | number (ms) | A buffer subtracted from maxExecutionTime to ensure the current node finishes cleanly before the timeout fires. Set this a little larger than your longest-executing node. |
Why This Matters
For graceful timeout handling, a serverless timeout should never occur in the middle of a node execution. If it does, automatic handling will break.
safeBuffer exists to prevent exactly this. When the time remaining drops below the buffer threshold, Cascaide stops dispatching new nodes and winds down gracefully ensuring that the in-flight node has time to complete and persist its state before the function is killed. Once the function is killed, cascaide will revive it and resume execution.
If automatic handling does fail, you can still resume by hydrating from the last known good node execution.