@imqueue/rpc 3.3.1 → 3.4.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 +65 -0
- package/package.json +1 -1
- package/src/IMQClient.js +14 -7
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Notable changes to `@imqueue/rpc`. Entries start at 3.3.1 — the first release
|
|
4
|
+
whose behavior changes needed a written record; earlier history is in the git
|
|
5
|
+
log.
|
|
6
|
+
|
|
7
|
+
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
8
|
+
|
|
9
|
+
## [Unreleased]
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- **On a delayed call, a trailing `undefined` is never delivered.** Every
|
|
14
|
+
trailing placeholder is now dropped, and the drop runs *after* both framework
|
|
15
|
+
slots have been stripped. 3.3.1 dropped exactly one, and did it before the
|
|
16
|
+
metadata slot was taken, so whether a placeholder reached the service depended
|
|
17
|
+
on whether metadata was also passed:
|
|
18
|
+
|
|
19
|
+
| call | 3.3.1 sends | now sends |
|
|
20
|
+
| --- | --- | --- |
|
|
21
|
+
| `m(a, undefined, undefined, delay)` | `[a, null]` | `[a]` |
|
|
22
|
+
| `m(a, undefined, metadata, delay)` | `[a, null]` | `[a]` |
|
|
23
|
+
|
|
24
|
+
A declared optional or defaulted parameter skipped this way therefore falls
|
|
25
|
+
back to its default instead of receiving `null`. If a handler persisted such a
|
|
26
|
+
parameter, it now writes the default rather than `null`.
|
|
27
|
+
|
|
28
|
+
Unchanged: calls without a delay never drop anything, declared arguments
|
|
29
|
+
holding real values are always delivered, and every shape 3.3.1 fixed keeps
|
|
30
|
+
working.
|
|
31
|
+
|
|
32
|
+
## [3.3.1] - 2026-07-25
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
|
|
36
|
+
- A delayed call no longer requires inventing a metadata bag.
|
|
37
|
+
`method(data, undefined, delay)` previously failed with
|
|
38
|
+
`IMQ_RPC_INVALID_ARGS_COUNT`, because the two trailing framework parameters are
|
|
39
|
+
stripped by identity rather than by position and the explicit `undefined`
|
|
40
|
+
travelled on as a real call argument. One trailing `undefined` is now dropped
|
|
41
|
+
once a delay has been popped.
|
|
42
|
+
- The client generator stripped only one framework parameter that a service had
|
|
43
|
+
declared itself, so a service declaring both emitted a client with a
|
|
44
|
+
duplicated metadata parameter.
|
|
45
|
+
|
|
46
|
+
### Changed
|
|
47
|
+
|
|
48
|
+
Behavior deltas against 3.3.0. All three need a cast or plain JavaScript to
|
|
49
|
+
reach — the generated signatures reject them under `tsc` — but on 3.3.0 the cast
|
|
50
|
+
form was the only way to delay a call while skipping an optional parameter, so
|
|
51
|
+
that spelling does occur in real code:
|
|
52
|
+
|
|
53
|
+
- `method(undefined, delay)`, on a method whose declared parameters are all
|
|
54
|
+
required, previously delivered `null` and now fails with
|
|
55
|
+
`IMQ_RPC_INVALID_ARGS_COUNT`. Pass a real value.
|
|
56
|
+
- `method(a, undefined, delay as any)`, on a method with an optional declared
|
|
57
|
+
parameter, previously delivered `null` for it and now omits it, so a defaulted
|
|
58
|
+
parameter falls back to its default. This one is silent: no error, a different
|
|
59
|
+
value.
|
|
60
|
+
- For a service that declares its own `IMQMetadata` parameter, metadata passed
|
|
61
|
+
positionally into that slot now arrives as `request.metadata`, leaving the
|
|
62
|
+
service's own parameter `undefined`.
|
|
63
|
+
|
|
64
|
+
Note that on 3.3.1 the drop applies only to *delayed* calls: `method(a,
|
|
65
|
+
undefined)` without a delay still delivers `null`, on every version.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imqueue/rpc",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "Type-safe RPC framework for Node.js & TypeScript microservices over a Redis message queue — self-describing services generate their own strongly-typed clients (@imqueue framework)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"redis",
|
package/src/IMQClient.js
CHANGED
|
@@ -175,23 +175,30 @@ let IMQClient = (() => {
|
|
|
175
175
|
const from = this.queueName;
|
|
176
176
|
const to = this.serviceName;
|
|
177
177
|
let delay = 0;
|
|
178
|
+
let delayed = false;
|
|
178
179
|
let metadata;
|
|
179
180
|
if (args[args.length - 1] instanceof IMQDelay) {
|
|
180
181
|
delay = args.pop().ms;
|
|
182
|
+
delayed = true;
|
|
181
183
|
if (!isFinite(delay) || isNaN(delay) || delay < 0) {
|
|
182
184
|
delay = 0;
|
|
183
185
|
}
|
|
184
|
-
// The metadata slot sits between the declared arguments and the
|
|
185
|
-
// delay, so callers who only need a delay may skip it with an
|
|
186
|
-
// explicit `undefined`. Drop it here, or it would travel on as a
|
|
187
|
-
// real call argument and break the service-side args count check.
|
|
188
|
-
if (args.length && args[args.length - 1] === undefined) {
|
|
189
|
-
args.pop();
|
|
190
|
-
}
|
|
191
186
|
}
|
|
192
187
|
if (args[args.length - 1] instanceof IMQMetadata) {
|
|
193
188
|
metadata = args.pop();
|
|
194
189
|
}
|
|
190
|
+
// On a delayed call a trailing `undefined` is a placeholder, never a
|
|
191
|
+
// value: it is either the skipped metadata slot or a skipped optional
|
|
192
|
+
// argument, both of which the caller has to spell out to reach the delay
|
|
193
|
+
// in the last position. Delivering it would serialize to `null`, defeat
|
|
194
|
+
// a declared default and, for a method whose params are all required,
|
|
195
|
+
// fail the service-side args count check. Both framework slots are gone
|
|
196
|
+
// by now, so this runs the same whether or not metadata was passed.
|
|
197
|
+
if (delayed) {
|
|
198
|
+
while (args.length && args[args.length - 1] === undefined) {
|
|
199
|
+
args.pop();
|
|
200
|
+
}
|
|
201
|
+
}
|
|
195
202
|
const request = {
|
|
196
203
|
from,
|
|
197
204
|
method,
|