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

Workflows: fix getting a workflow when such workflow was not yet created #7520

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/lovely-fireants-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cloudflare/workflows-shared": patch
---

Fix getting a workflow when such workflow was not yet created
bruxodasilva marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion fixtures/import-npm/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions fixtures/workflow/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,15 @@ describe("Workflows", () => {
output: [],
});
});

it("fails getting a workflow without creating it first", async ({
expect,
}) => {
await expect(
fetchJson(`http://${ip}:${port}/status?workflowName=anotherTest`)
).resolves.toMatchObject({
message: "instance.not_found",
name: "Error",
});
});
});
5 changes: 5 additions & 0 deletions packages/workflows-shared/src/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ export class Engine extends DurableObject<Env> {
_accountId: number,
_instanceId: string
): Promise<InstanceStatus> {
// NOTE(dferreira): we need to verify if the engine was initialized or not
bruxodasilva marked this conversation as resolved.
Show resolved Hide resolved
if (this.accountId === undefined) {
throw new Error("stub not initialized");
}

const res = await this.ctx.storage.get<InstanceStatus>(ENGINE_STATUS_KEY);

// NOTE(lduarte): if status don't exist, means that engine is running for the first time, so we assume queued
Expand Down
Loading