windmill-labs/windmill · error · Error
No workflow() entrypoint found. Wrap your main function with
Error message
No workflow() entrypoint found. Wrap your main function with workflow().
What it means
For Windmill AI (WAC) workflow scripts in Bun, the generated wrapper scans the module's exports for the workflow entrypoint (typically a function wrapped by workflow()). If none of Main's exports qualify, it throws this error telling the author to wrap their main function with workflow().
Source
Thrown at backend/windmill-worker/src/bun_executor.rs:1934
return [ {spread} ];
}}
BigInt.prototype.toJSON = function () {{
return this.toString();
}};
// Find the workflow entrypoint (export default)
let workflowFn = Main.default;
if (!workflowFn || !workflowFn._is_workflow) {{
for (const key of Object.keys(Main)) {{
if (Main[key]?._is_workflow) {{
workflowFn = Main[key];
break;
}}
}}
}}
if (!workflowFn) {{
throw new Error("No workflow() entrypoint found. Wrap your main function with workflow().");
}}
async function run() {{
{dates}
{preprocessor}
const argsArr = {wac_spread};
const ctx = new WorkflowCtx(checkpoint);
setWorkflowCtx(ctx);
try {{
const result = await workflowFn(...argsArr);
setWorkflowCtx(null);
const failed = ctx._takePendingStepFailure?.();
if (failed) {{
throw failed.error;
}}
const swallowed = ctx._takePendingSuspend?.();View on GitHub (pinned to e474e8803c)
Solutions
- Wrap the main function with workflow() and export it: `export const main = workflow(async (...) => {...})` per the WAC script template.
- Verify the workflow-wrapped function is exported from the module.
- If the script shouldn't be a workflow, change the script's kind instead of the code.
Example fix
// before
async function main(a, b) { return a + b; }
// after
export const main = workflow(async (a, b) => {
return a + b;
}); Defensive patterns
Strategy: validation
Validate before calling
// Lint check for WAC workflow scripts before deploy
if (scriptKind === 'wac-workflow' && !/export\s+const\s+\w+\s*=\s*workflow\(/.test(source)) {
throw new Error('WAC workflow script must export a workflow()-wrapped entrypoint');
} Try / catch
try {
await windmill.runScript(path, hash_, args);
} catch (e) {
if (e.message.includes('No workflow() entrypoint found')) {
console.error('Wrap main with workflow() and export it: export const main = workflow(async (...) => {...})');
}
throw e;
} Prevention
- Start WAC workflow scripts from the official template that already wraps main.
- Never rename the workflow-wrapped export away from what the wrapper scans for.
- Add a CI lint asserting the workflow() wrapper exists for workflow-kind scripts.
When it happens
Trigger: Running a Bun WAC-workflow script whose module has no export that the wrapper recognizes as the workflow entrypoint — e.g. the main function is defined but never wrapped with workflow(), or it isn't exported.
Common situations: Writing a plain script in a workflow-type script (missing the workflow() wrapper), renaming the wrapped function so the wrapper's export scan misses it, or exporting only helpers.
Related errors
- preprocessor function is missing
- ${main_name} function is missing
- WAC step key "${options.key}" is already used in this workfl
- taskScript("${path}") can only be called inside a workflow()
- taskFlow("${path}") can only be called inside a workflow()
AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03).
Data as JSON: /api/errors/11457618c8735d7d.
Report an issue: GitHub.