Comparing version 4.12.6 to 4.12.7
@@ -0,1 +1,8 @@ | ||
## [4.12.7](https://github.com/OptimalBits/bull/compare/v4.12.6...v4.12.7) (2024-05-21) | ||
### Bug Fixes | ||
* **scripts:** throw error when moving non-active job to delayed ([#2740](https://github.com/OptimalBits/bull/issues/2740)) ([63636b1](https://github.com/OptimalBits/bull/commit/63636b181d0a166b1702059e5abb53ce1589d90f)) | ||
## [4.12.6](https://github.com/OptimalBits/bull/compare/v4.12.5...v4.12.6) (2024-05-18) | ||
@@ -2,0 +9,0 @@ |
@@ -342,3 +342,3 @@ 'use strict'; | ||
if (code < 0) { | ||
throw scripts.finishedErrors(code, this.id, command); | ||
throw scripts.finishedErrors(code, this.id, command, 'active'); | ||
} | ||
@@ -345,0 +345,0 @@ }; |
@@ -241,3 +241,3 @@ /** | ||
if (result < 0) { | ||
throw scripts.finishedErrors(result, job.id, 'finished'); | ||
throw scripts.finishedErrors(result, job.id, 'finished', 'active'); | ||
} else if (result) { | ||
@@ -250,3 +250,3 @@ return raw2jobData(result); | ||
finishedErrors(code, jobId, command) { | ||
finishedErrors(code, jobId, command, state) { | ||
switch (code) { | ||
@@ -257,2 +257,6 @@ case -1: | ||
return new Error('Missing lock for job ' + jobId + ' ' + command); | ||
case -3: | ||
return new Error(`Job ${jobId} is not in the ${state} state. ${command}`); | ||
case -6: | ||
return new Error(`Lock mismatch for job ${jobId}. Cmd ${command} from ${state}`); | ||
} | ||
@@ -259,0 +263,0 @@ }, |
@@ -20,17 +20,32 @@ 'use strict'; | ||
local rcall = redis.call | ||
if rcall("EXISTS", KEYS[3]) == 1 then | ||
-- Check for job lock | ||
if ARGV[3] ~= "0" then | ||
local lockKey = KEYS[3] .. ':lock' | ||
if rcall("GET", lockKey) == ARGV[3] then | ||
-- Includes | ||
local function removeLock(jobKey, stalledKey, token, jobId) | ||
if token ~= "0" then | ||
local lockKey = jobKey .. ':lock' | ||
local lockToken = rcall("GET", lockKey) | ||
if lockToken == token then | ||
rcall("DEL", lockKey) | ||
rcall("SREM", KEYS[4], ARGV[2]) | ||
rcall("SREM", stalledKey, jobId) | ||
else | ||
return -2 | ||
if lockToken then | ||
-- Lock exists but token does not match | ||
return -6 | ||
else | ||
-- Lock is missing completely | ||
return -2 | ||
end | ||
end | ||
end | ||
return 0 | ||
end | ||
if rcall("EXISTS", KEYS[3]) == 1 then | ||
local errorCode = removeLock(KEYS[3], KEYS[4], ARGV[3], ARGV[2]) | ||
if errorCode < 0 then | ||
return errorCode | ||
end | ||
local numRemovedElements = rcall("LREM", KEYS[1], -1, ARGV[2]) | ||
if numRemovedElements < 1 then return -3 end | ||
local score = tonumber(ARGV[1]) | ||
rcall("ZADD", KEYS[2], score, ARGV[2]) | ||
rcall("PUBLISH", KEYS[2], (score / 0x1000)) | ||
rcall("LREM", KEYS[1], 0, ARGV[2]) | ||
return 0 | ||
@@ -37,0 +52,0 @@ else |
{ | ||
"name": "bull", | ||
"version": "4.12.6", | ||
"version": "4.12.7", | ||
"description": "Job manager", | ||
@@ -5,0 +5,0 @@ "engines": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
291976
73
5964