-
Notifications
You must be signed in to change notification settings - Fork 734
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 multiple workflows and add proper engine persistance #7286
Conversation
🦋 Changeset detectedLatest commit: 4a17f40 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
f858f6c
to
9371733
Compare
A wrangler prerelease is available for testing. You can install this latest build in your project with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11940185264/npm-package-wrangler-7286 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/7286/npm-package-wrangler-7286 Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11940185264/npm-package-wrangler-7286 dev path/to/script.js Additional artifacts:npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11940185264/npm-package-create-cloudflare-7286 --no-auto-update npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11940185264/npm-package-cloudflare-kv-asset-handler-7286 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11940185264/npm-package-miniflare-7286 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11940185264/npm-package-cloudflare-pages-shared-7286 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11940185264/npm-package-cloudflare-vitest-pool-workers-7286 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11940185264/npm-package-cloudflare-workers-editor-shared-7286 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11940185264/npm-package-cloudflare-workers-shared-7286 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11940185264/npm-package-cloudflare-workflows-shared-7286 Note that these links will no longer work once the GitHub Actions artifact expires.
Please ensure constraints are pinned, and |
@@ -62,15 +62,20 @@ export const WORKFLOWS_PLUGIN: Plugin< | |||
sharedOptions.workflowsPersist | |||
); | |||
await fs.mkdir(persistPath, { recursive: true }); | |||
const storageService: Service = { | |||
name: WORKFLOWS_STORAGE_SERVICE_NAME, | |||
// each workflow should get its own storage service |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sanity check for me: why does each workflow need its own storage service? as far as i can tell all other plugins use one storage service for all instances.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was personal preference mostly - this way each workflow gets its own folder in .wrangler/workflow
and makes it way easier to debug the engine state
Will adding persistence enable workflows to return serializable values like steps do? This would be great to compose workflows. |
I'm sorry, not sure what you mean by that - afaik you shouldn't have any problem composing workflows atm |
I meant being able to call a workflow and get the return value. Right now you can only compose by having them triggering each other, like queues. But it would be great to be able to have them act like steps, with a return value. This is how it's implemented at inngest: https://www.inngest.com/docs/reference/functions/step-invoke |
That is unrelated to the PR - but you can already do this - you can pass the workflow output as an event payload to the next. What you are describing is syntactic sugar for that, which we might (or might not) consider in the future 😄 thanks ^^ |
520685f
to
ec0404b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good from the wrangler side pending a tiny fixup
764a168
to
4a17f40
Compare
@LuisDuarte1 you're my hero man. multiple workflows on local working great now! |
Fixes #7127.
Closes WOR-322, WOR-395
Previously, engine did store everything in-memory - this is not expected behaviour since R2/KV/DOs all have persistenece, by default.
Also, multiple workflow definitions were broken since the DO unique key was a constant (therefore it would fail when workerd launched)