Repository navigation
test: separate a retried trigger from a new trigger with the same run id - #219
Merged
Merged
Conversation
With Upstash-Workflow-CreatedAt in the deduplication of workflow requests (upstash/qstash-server#1129), the trigger time decides whether a trigger with a taken run id is a duplicate. The old test triggered twice with a fresh trigger time each time, so against a server with #1129 the second trigger is a new trigger, not a retry, and is rejected instead of being deduplicated. - A retried trigger sends the same trigger time, and is still deduplicated with "workflow-run-already-exists" and a warning. - A new trigger for the id of a run in progress returns an error, because the run id is taken. The runs are cancelled by id: the contexts hold the trigger time, not the creation time of the run, and a delete with a different creation time is ignored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017dm7F4hg2khgYDqBwP9nx5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Workflow Requests > should omit some errors > should omit the error if the workflow is created with the same idfails when the SDK tests run against a QStash built from upstash/qstash-server#1129.That's expected. Since #214, a trigger carries
Upstash-Workflow-CreatedAt, and #1129 adds it to the deduplication of workflow requests. So the trigger time now decides whether a trigger for a taken run id counts as a duplicate. The old test built two contexts withworkflowRunCreatedAt: 0, sotriggerFirstInvocationgave each one its ownDate.now(). Against #1129, the second trigger is therefore a new trigger, not a retry. It isn't deduplicated; QStash rejects it with400 a workflow already exists, can not initialize a new one with same id.Change
The test is split into the two cases it now covers, in
src/workflow-requests.test.ts:should omit the error if the same trigger is retried: both triggers carry the same trigger time, as a retry of the same request does. The second one is deduplicated and returns"workflow-run-already-exists"with the warning, as before. The server PR tests the same thing ("A retry of the same trigger is deduplicated").should return an error if a new trigger uses the id of a run in progress: the second trigger has a different trigger time, so it's a new trigger. It returns an error containing "a workflow already exists".Cleanup now uses
workflowClient.cancel([workflowRunId]), like the other tests in this block, instead oftriggerWorkflowDelete. The contexts hold the trigger time, not the run's actual creation time, and since #1129 QStash ignores a delete whose creation time doesn't match.Notes
QSTASH_TOKEN). The second test only passes against a QStash with #1129. Production QStash without it still deduplicates the second trigger, so it would return"workflow-run-already-exists"instead of an error. It'll fail in this repo's CI until #1129 is deployed.tsc,eslintandprettier --checkpass. The error message checked is the one a local QStash built from #1129 returned for a secondclient.triggerwhile the run was in progress.🤖 Generated with Claude Code
https://claude.ai/code/session_017dm7F4hg2khgYDqBwP9nx5