windmill-labs/windmill · error · Error
preprocessor function is missing
Error message
preprocessor function is missing
What it means
This error is thrown from the generated Deno wrapper script when a workspace has a preprocessor function configured (e.g. via the 'preprocessor' extra import/entrypoint in main.ts) but the deployed module does not actually export a callable `preprocessor`. The worker synthesizes a script that imports { preprocessor } from "./main.ts" and checks `typeof preprocessor !== 'function'` before calling it, so a missing/renamed/non-function export aborts the job before the main function ever runs.
Source
Thrown at backend/windmill-worker/src/deno_executor.rs:316
} else {
None
}
})
.map(|x| {
return format!(r#"args["{x}"] = args["{x}"] ? new Date(args["{x}"]) : undefined"#);
})
.join("\n ");
let spread = args.into_iter().map(|x| x.name).join(",");
let main_name = main_override.unwrap_or("main");
// logs.push_str(format!("infer args: {:?}\n", start.elapsed().as_micros()).as_str());
let (preprocessor_import, preprocessor) = if let Some(pre_args) = pre_args {
let pre_spread = pre_args.into_iter().map(|x| x.name).join(",");
(
r#"import { preprocessor } from "./main.ts";"#.to_string(),
format!(
r#"if (preprocessor === undefined || typeof preprocessor !== 'function') {{
throw new Error("preprocessor function is missing");
}}
function preArgsObjToArr({{ {pre_spread} }}) {{
return [ {pre_spread} ];
}}
args = await preprocessor(...preArgsObjToArr(args));
const args_json = JSON.stringify(args ?? null, (key, value) => typeof value === 'undefined' ? null : value);
await Deno.writeTextFile("args.json", args_json);"#
),
)
} else {
("".to_string(), "".to_string())
};
let wrapper_content: String = format!(
r#"
import {{ {main_name} }} from "./main.ts";
{preprocessor_import}
View on GitHub (pinned to e474e8803c)
Solutions
- Add `export async function preprocessor(args) { ... return transformedArgs; }` to the script's entry file (the module imported as ./main.ts)
- If the script needs no input transformation, remove the preprocessor configuration (pre_args) from the workspace/script settings so the wrapper stops importing it
- Check the export is spelled exactly `preprocessor` and is a function (not a const object or undefined)
- Verify the deployed script actually saved — an unsaved editor buffer or stale deployed version may lack the export
Example fix
// before
export const preprocessor; // undefined — not a function
// after
export async function preprocessor(...args: any[]): Promise<any[]> {
const [a, b] = args;
return [a, b];
} Defensive patterns
Strategy: validation
Validate before calling
// in the script entry file, before relying on it:
if (typeof preprocessor !== 'function') {
throw new Error('main.ts must export a `preprocessor` function when preprocessor args are configured');
} Type guard
function isPreprocessorFn(v: unknown): v is (...args: unknown[]) => Promise<unknown[]> | unknown[] {
return typeof v === 'function';
} Prevention
- Start every Deno script from a template that includes the preprocessor export when workspace preprocessor args are enabled
- Keep preprocessor config and script exports in lockstep: remove pre_args when a script doesn't need them
- Lint scripts for `export function/const preprocessor` in CI when the workspace has preprocessor enabled
When it happens
Trigger: Running a Deno/Bun/TypeScript script or flow step whose workspace or script settings define preprocessor args (pre_args), while the script's entry module fails to export `preprocessor` — e.g. export was deleted, renamed, or exported as a non-function value.
Common situations: A preprocessor was configured in workspace settings (Settings > Workspace > Preprocessor) but the user's script is a fresh template that doesn't define one; a Windmill version upgrade or template change renamed the export; someone wrote `export const preprocessor = someUndefinedValue` or exported it from a different module than the entrypoint main.ts.
Related errors
- preprocessor function is missing
- ${main_name} function is missing
- ${main_name} function is missing
- The connection check did not run. Is a worker listening to t
- preprocessor function is missing
AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03).
Data as JSON: /api/errors/e02510b5c57a317e.
Report an issue: GitHub.