Is `$.flow.rerun()` Now Supported in the Builder?

This topic was automatically generated from Slack. You can find the original thread here.

Is it just me or is $.flow.rerun() now supported in the builder?!? :open_mouth:

Previously, it would say something like ā€œWorkflow would have pausedā€.

But now it actually seems to run and receive callbacks at the resume_url! :rocket:

Itā€™s a nice & welcome surprise! :smile:

, @U02SX7ETBFB: I ran into a weird issue though, because when the resume_url was called by a webhook/callback, it resumed the workflow three times. I know because I received three Slack notifications that the workflow had competed. :sweat_smile:

Not a big deal since itā€™s just the builder, but probably something to fix eventually.

Thanks for reporting! Iā€™ll test this ASAP

It might be an edge caseā€¦ let me know if you need help reproducing.

Iā€™m trying to repro in the builder but the only consistent result Iā€™m getting is that whenever $.flow.rerun() is called it never ends the step testing (though the code itself is executed)

E.g.

export default defineComponent({
  props: {
    data_store: {
      type: "data_store"
    }
  },
  async run({ steps, $ }) {
    let count = await this.data_store.get("count") || 0
    if (count > 0) {
      console.log("done")
      await this.data_store.set("count", 0)
    } else {
      console.log("Hi!")
      await this.data_store.set("count", count + 1)
      $.flow.rerun(5000, null, 1)
    }
  },
})

I test once and the $.flow.rerun(5000, null, 1) is called, the data_store count is set to 1 but the step never finishes

If I cancel the testing and test again, it logs on console.log("done")

Iā€™ve tried $.export("rerun", $.flow.rerun(5000, null, 1)) but it shows only in a deployed execution

I donā€™t think the suspend/resume functionality is working in the builder yet.

See this thread.

But if you call the resume_url by hand (you can just console.log() it), it should resume the workflow (possibly more than once).

Oh, so youā€™re talking about on a deployed workflow or on the builder?
Iā€™m trying to get it to resume more than once, but am not successful

On the builder.

Once deployed, everything works normally.

Iā€™ll try to reproduce it again.

Ah, console.log() doesnā€™t work to get the resume_url :man-facepalming:

Iā€™ll put it into the data store instead. :man-shrugging:

Just tried with this simple code:

export default defineComponent({
  props: {
    ds: {
      type: "data_store"
    }
  },
  async run({ steps, $ }) {
    if ($.context.run.runs === 1) {
      await this.ds.set(
        'test_rerun',
        $.flow.rerun(5000, null, 1)
      );
    } else {
      console.log('resumed');
      await this.ds.set(Math.random().toString(36), Date.now());
    }
  },
})

And I couldnā€™t reproduce it at first, until I realized that our callback workflow calls the resume_url multiple times (to handle cases when the resume fails silently).