@mastra/upstash 1.4.1 → 1.4.2-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +25 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -2
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @mastra/upstash
|
|
2
2
|
|
|
3
|
+
## 1.4.2-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed concurrent resume() calls on the same suspended workflow run executing downstream steps more than once. A resume now atomically claims the run before executing anything, so only one caller continues a given suspension. Losing callers throw WORKFLOW_RESUME_ALREADY_CLAIMED without running any steps. Fixes #20443 ([#21725](https://github.com/mastra-ai/mastra/pull/21725))
|
|
8
|
+
|
|
9
|
+
- Workflow state updates now support an optional expectedStatus guard, so a status change is only applied when the stored run is in an expected state. This is what makes concurrent workflow resumes safe. ([#21725](https://github.com/mastra-ai/mastra/pull/21725))
|
|
10
|
+
|
|
11
|
+
- Resume conflicts now return 409 Conflict. When a suspended workflow run has already been resumed by another caller, the resume endpoints respond with 409 instead of a generic error. ([#21725](https://github.com/mastra-ai/mastra/pull/21725))
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`88d14ca`](https://github.com/mastra-ai/mastra/commit/88d14cac008582a618fecc3d5c7fd3bdf4f6ddc3), [`84a5b69`](https://github.com/mastra-ai/mastra/commit/84a5b699f84d6bae0a34efe5a970d891090b9f41), [`84a5b69`](https://github.com/mastra-ai/mastra/commit/84a5b699f84d6bae0a34efe5a970d891090b9f41), [`84a5b69`](https://github.com/mastra-ai/mastra/commit/84a5b699f84d6bae0a34efe5a970d891090b9f41), [`038b7b4`](https://github.com/mastra-ai/mastra/commit/038b7b405cb4ac25ab3f3031334111b1f87ac112), [`4132d61`](https://github.com/mastra-ai/mastra/commit/4132d61f8367077120ee9e6420d3224dffd93c93)]:
|
|
14
|
+
- @mastra/core@1.60.1-alpha.0
|
|
15
|
+
- @mastra/redis@1.4.2-alpha.0
|
|
16
|
+
|
|
3
17
|
## 1.4.1
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/docs/SKILL.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1729,10 +1729,11 @@ var WorkflowsUpstash = class extends _mastra_core_storage.WorkflowsStorage {
|
|
|
1729
1729
|
run_id: runId
|
|
1730
1730
|
});
|
|
1731
1731
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1732
|
-
const
|
|
1732
|
+
const luaScript = `
|
|
1733
1733
|
local key = KEYS[1]
|
|
1734
1734
|
local optsJson = ARGV[1]
|
|
1735
1735
|
local now = ARGV[2]
|
|
1736
|
+
local expectedStatusJson = ARGV[3]
|
|
1736
1737
|
|
|
1737
1738
|
-- Get existing data
|
|
1738
1739
|
local existing = redis.call('GET', key)
|
|
@@ -1752,6 +1753,21 @@ var WorkflowsUpstash = class extends _mastra_core_storage.WorkflowsStorage {
|
|
|
1752
1753
|
return nil
|
|
1753
1754
|
end
|
|
1754
1755
|
|
|
1756
|
+
-- Compare-and-set guard: bail out unless the persisted status is one the caller expects.
|
|
1757
|
+
-- This runs inside the same script as the write, so the check and the write are atomic.
|
|
1758
|
+
if expectedStatusJson ~= '' then
|
|
1759
|
+
local expected = cjson.decode(expectedStatusJson)
|
|
1760
|
+
local matched = false
|
|
1761
|
+
for _, status in ipairs(expected) do
|
|
1762
|
+
if snapshot.status == status then
|
|
1763
|
+
matched = true
|
|
1764
|
+
end
|
|
1765
|
+
end
|
|
1766
|
+
if not matched then
|
|
1767
|
+
return nil
|
|
1768
|
+
end
|
|
1769
|
+
end
|
|
1770
|
+
|
|
1755
1771
|
-- Merge the new options with the existing snapshot
|
|
1756
1772
|
local opts = cjson.decode(optsJson)
|
|
1757
1773
|
for k, v in pairs(opts) do
|
|
@@ -1767,7 +1783,14 @@ var WorkflowsUpstash = class extends _mastra_core_storage.WorkflowsStorage {
|
|
|
1767
1783
|
|
|
1768
1784
|
-- Return the full updated data
|
|
1769
1785
|
return cjson.encode(data)
|
|
1770
|
-
|
|
1786
|
+
`;
|
|
1787
|
+
const { expectedStatus, ...state } = opts;
|
|
1788
|
+
const expectedStatusJson = expectedStatus === void 0 ? "" : JSON.stringify(Array.isArray(expectedStatus) ? expectedStatus : [expectedStatus]);
|
|
1789
|
+
const resultJson = await this.client.eval(luaScript, [key], [
|
|
1790
|
+
JSON.stringify(state),
|
|
1791
|
+
now,
|
|
1792
|
+
expectedStatusJson
|
|
1793
|
+
]);
|
|
1771
1794
|
if (!resultJson) return;
|
|
1772
1795
|
let data;
|
|
1773
1796
|
if (typeof resultJson === "string") data = JSON.parse(resultJson);
|