@pikku/queue-pg-boss 0.12.6 → 0.12.7
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 +11 -0
- package/dist/pg-boss-queue-service.js +12 -9
- package/package.json +2 -2
- package/run-tests.sh +54 -3
- package/src/pg-boss-queue-service.test.ts +14 -6
- package/src/pg-boss-queue-service.ts +14 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
## 0.12.7
|
|
2
|
+
|
|
3
|
+
### Patch Changes
|
|
4
|
+
|
|
5
|
+
- 6c30861: fix workflow step retry backoff firing immediately
|
|
6
|
+
- `@pikku/queue-pg-boss`: `backoff: 'exponential'` mapped to `retryBackoff: true` without a base `retryDelay`; pg-boss computes exponential backoff as `retry_delay * 2^n` with a queue default of 0, so every retry fired immediately. Exponential backoff now gets a 1s base delay, and sub-second fixed delays round up to 1s instead of flooring to 0 (= immediate).
|
|
7
|
+
- `@pikku/core`: a duration-string `retryDelay` (e.g. `'15s'`) on a workflow step was silently dropped (only numbers were honored) and fell back to exponential. It now resolves to a fixed backoff via `getDurationInMilliseconds`.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [6c30861]
|
|
10
|
+
- @pikku/core@0.12.56
|
|
11
|
+
|
|
1
12
|
## 0.12.6
|
|
2
13
|
|
|
3
14
|
### Patch Changes
|
|
@@ -15,16 +15,19 @@ export const mapPikkuJobToPgBoss = (options) => {
|
|
|
15
15
|
pgBossOptions.retryLimit = options.attempts - 1;
|
|
16
16
|
}
|
|
17
17
|
if (options?.backoff !== undefined) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const type = typeof options.backoff === 'string' ? options.backoff : options.backoff.type;
|
|
19
|
+
const delay = typeof options.backoff === 'object' ? options.backoff.delay : undefined;
|
|
20
|
+
pgBossOptions.retryBackoff = type === 'exponential';
|
|
21
|
+
if (delay !== undefined) {
|
|
22
|
+
// pg-boss uses seconds, we use milliseconds — never round a sub-second
|
|
23
|
+
// delay down to 0, which pg-boss treats as retry-immediately
|
|
24
|
+
pgBossOptions.retryDelay = Math.max(1, Math.round(delay / 1000));
|
|
21
25
|
}
|
|
22
|
-
else if (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
26
|
+
else if (type === 'exponential') {
|
|
27
|
+
// pg-boss computes exponential backoff as retry_delay * 2^n, and the
|
|
28
|
+
// queue-level retry_delay defaults to 0 — without an explicit base every
|
|
29
|
+
// "exponential" retry fires immediately. 1s base → ~1s, 2s, 4s, 8s…
|
|
30
|
+
pgBossOptions.retryDelay = 1;
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
33
|
if (options?.removeOnComplete !== undefined) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikku/queue-pg-boss",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.7",
|
|
4
4
|
"author": "yasser.fadl@gmail.com",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"prepublishOnly": "yarn build"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"@pikku/core": "^0.12.
|
|
18
|
+
"@pikku/core": "^0.12.56"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"pg-boss": "^12.14.0"
|
package/run-tests.sh
CHANGED
|
@@ -1,5 +1,56 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
4
|
+
cd "$script_dir"
|
|
5
|
+
|
|
6
|
+
# Enable nullglob to handle cases where no files match the pattern
|
|
7
|
+
shopt -s nullglob
|
|
8
|
+
|
|
9
|
+
# Initialize variables for options
|
|
10
|
+
watch_mode=false
|
|
11
|
+
coverage_mode=false
|
|
12
|
+
|
|
13
|
+
# Parse command-line options
|
|
14
|
+
while [[ $# -gt 0 ]]; do
|
|
15
|
+
case $1 in
|
|
16
|
+
--watch)
|
|
17
|
+
watch_mode=true
|
|
18
|
+
shift
|
|
19
|
+
;;
|
|
20
|
+
--coverage)
|
|
21
|
+
coverage_mode=true
|
|
22
|
+
shift
|
|
23
|
+
;;
|
|
24
|
+
*)
|
|
25
|
+
echo "Unknown option: $1"
|
|
26
|
+
exit 1
|
|
27
|
+
;;
|
|
28
|
+
esac
|
|
29
|
+
done
|
|
30
|
+
|
|
31
|
+
# Define the pattern to match your test files
|
|
32
|
+
pattern="src/*.test.ts"
|
|
33
|
+
|
|
34
|
+
# Expand the pattern into an array of files
|
|
3
35
|
files=($(find src -type f -name "*.test.ts"))
|
|
4
|
-
|
|
5
|
-
|
|
36
|
+
|
|
37
|
+
# Check if any files matched the pattern
|
|
38
|
+
if [ ${#files[@]} -eq 0 ]; then
|
|
39
|
+
echo "No test files found matching pattern: $pattern"
|
|
40
|
+
exit 0
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
# Construct the node command
|
|
44
|
+
node_cmd=(node --import tsx --test)
|
|
45
|
+
|
|
46
|
+
# Append options based on flags
|
|
47
|
+
if [ "$watch_mode" = true ]; then
|
|
48
|
+
node_cmd+=(--watch)
|
|
49
|
+
fi
|
|
50
|
+
|
|
51
|
+
if [ "$coverage_mode" = true ]; then
|
|
52
|
+
node_cmd+=(--test-coverage-include="src/**/*.{ts,js}" --test-coverage-exclude="**/dist/**" --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=lcov.info)
|
|
53
|
+
fi
|
|
54
|
+
|
|
55
|
+
# Execute the node command with the expanded list of files
|
|
56
|
+
"${node_cmd[@]}" "${files[@]}"
|
|
@@ -16,12 +16,20 @@ describe('mapPikkuJobToPgBoss — retry mapping', () => {
|
|
|
16
16
|
assert.equal(mapPikkuJobToPgBoss({ attempts: 1 }).retryLimit, 0)
|
|
17
17
|
})
|
|
18
18
|
|
|
19
|
-
test("backoff 'exponential' → retryBackoff true", () => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
)
|
|
19
|
+
test("backoff 'exponential' → retryBackoff true + 1s base delay", () => {
|
|
20
|
+
const opts = mapPikkuJobToPgBoss({ attempts: 6, backoff: 'exponential' })
|
|
21
|
+
assert.equal(opts.retryBackoff, true)
|
|
22
|
+
// pg-boss multiplies retry_delay by 2^n and the queue default is 0 —
|
|
23
|
+
// without a base, "exponential" retries all fire immediately.
|
|
24
|
+
assert.equal(opts.retryDelay, 1)
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
test('sub-second fixed delay rounds up to 1s, not down to immediate', () => {
|
|
28
|
+
const opts = mapPikkuJobToPgBoss({
|
|
29
|
+
attempts: 4,
|
|
30
|
+
backoff: { type: 'fixed', delay: 300 },
|
|
31
|
+
})
|
|
32
|
+
assert.equal(opts.retryDelay, 1)
|
|
25
33
|
})
|
|
26
34
|
|
|
27
35
|
test('fixed backoff → retryBackoff false + retryDelay in seconds', () => {
|
|
@@ -25,15 +25,20 @@ export const mapPikkuJobToPgBoss = (
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
if (options?.backoff !== undefined) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
const type =
|
|
29
|
+
typeof options.backoff === 'string' ? options.backoff : options.backoff.type
|
|
30
|
+
const delay =
|
|
31
|
+
typeof options.backoff === 'object' ? options.backoff.delay : undefined
|
|
32
|
+
pgBossOptions.retryBackoff = type === 'exponential'
|
|
33
|
+
if (delay !== undefined) {
|
|
34
|
+
// pg-boss uses seconds, we use milliseconds — never round a sub-second
|
|
35
|
+
// delay down to 0, which pg-boss treats as retry-immediately
|
|
36
|
+
pgBossOptions.retryDelay = Math.max(1, Math.round(delay / 1000))
|
|
37
|
+
} else if (type === 'exponential') {
|
|
38
|
+
// pg-boss computes exponential backoff as retry_delay * 2^n, and the
|
|
39
|
+
// queue-level retry_delay defaults to 0 — without an explicit base every
|
|
40
|
+
// "exponential" retry fires immediately. 1s base → ~1s, 2s, 4s, 8s…
|
|
41
|
+
pgBossOptions.retryDelay = 1
|
|
37
42
|
}
|
|
38
43
|
}
|
|
39
44
|
|