ShenanigansS
Windmill8mo ago
4 replies
Shenanigans

Invalid flow failure while handling flow error

Hello, I have recently encountered an error within my flows error handler I can't explain/understand. My error handler is to read the flows state and write it to a database via the following bun script below
import * as wmill from "windmill-client"


export async function main(message: string, name: string, step_id: string, profileName: string) {
  console.log("message", message)
  console.log("name", name)
  console.log("step_id", step_id)

  const err_msg = await wmill.getFlowUserState("err_msg", true)
  const errSource = await wmill.getFlowUserState("errSource", true)
  const poDate = await wmill.getFlowUserState("poDate", true)
  // ...

  console.log(err_msg)
  console.log(errSource)
  console.log(poDate)

  const database = await wmill.getResource('f/client_orgitem_sync/postgre_db_neondb')

  const orgitemStatusArgs = {
    database,
    metadata: orgitemMetadata,
    created_at: new Date().toISOString(),
    error_msg: err_msg,
    errSource: errSource,
    poDate: poDate,
    // ...
    
  }

  const res = await wmill.runScript("f/client_orgitem_sync/submit-myorg-status", null, orgitemStatusArgs)

  return res


But I encounter the error below
6870 | // main.ts
6871 | var wmill = __toESM(require_dist(), 1);
6872 | async function main(message, name, step_id, profileName) {
6873 |   let flow_id = process.env.WM_ROOT_FLOW_JOB_ID;
6874 |   console.log("message", message), console.log("name", name), console.log("step_id", step_id);
6875 |   console.log(err_msg), console.log(errSource), console.log(poDate);
                                                                  ^
TypeError: Right side of assignment cannot be destructured
      at <anonymous> (/tmp/bun/main.js:6875:141)


This would eventually lead to the flow crashing(img) and the called script in the error handler not having a log entry for that flow run. The flow ran on 29/05 05:00 UTC. Was there perhaps an update to windmill that occurred then that may have caused this error?
image.png
Was this page helpful?