Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix getting error on create workflow through env.MY_WORKFLOW.create() #7135

Open
sanyaches opened this issue Oct 31, 2024 · 2 comments · May be fixed by #7225
Open

Fix getting error on create workflow through env.MY_WORKFLOW.create() #7135

sanyaches opened this issue Oct 31, 2024 · 2 comments · May be fixed by #7225

Comments

@sanyaches
Copy link

sanyaches commented Oct 31, 2024

If I create a workflow regarding docs

> // Spawn a new instance and return the ID and status
> let instance = await env.MY_WORKFLOW.create();

I will get the following error
✘ [ERROR] Uncaught (in promise) TypeError: Cannot destructure property 'id' of 'undefined' as it is undefined.

In the binding file above you can see the root problem, the compiler tries to destructure the coming object, but there is no param in the docs example

@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Oct 31, 2024
@sanyaches sanyaches changed the title Fix getting error on create Fix getting error on create workflow through env.MY_WORKFLOW.create() Oct 31, 2024
@sanyaches
Copy link
Author

So we need to pass at least an empty object to create workflow

@gmemstr
Copy link
Contributor

gmemstr commented Nov 4, 2024

I'm of two minds - it's kind of nice being able to generate a custom run ID (e.g if someone would rather use a timestamp over a UUID), but also, being able to call it without any args is less onus on the developer.

fwiw I took this approach

let id = crypto.randomUUID();
let instance = await env.WORKFLOW.create({id: id});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Untriaged
3 participants