@zudojs/messaging 1.2.0 → 1.2.1
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/README.md
CHANGED
|
@@ -117,6 +117,11 @@ that ignores its signal. `handlerResults` still lists every handler that
|
|
|
117
117
|
finished. Before 1.2.0 an abort during the last handler was reported as
|
|
118
118
|
`success: true`.
|
|
119
119
|
|
|
120
|
+
Cancellation uses only `AbortSignal` and `setTimeout`, so it works in
|
|
121
|
+
browsers and other non-Node runtimes. 1.2.0 scheduled the abort with Node's
|
|
122
|
+
`setImmediate`, and aborting a dispatch in a browser threw
|
|
123
|
+
`ReferenceError: setImmediate is not defined`; later releases do not.
|
|
124
|
+
|
|
120
125
|
## Timeouts
|
|
121
126
|
|
|
122
127
|
`timeout` is honoured by the dispatcher itself, so it applies whether you hold
|
|
@@ -33,6 +33,11 @@ export declare function assertDispatchNotAborted(signal: AbortSignal, message: M
|
|
|
33
33
|
* The rejection waits one macrotask. A handler that aborts and then returns
|
|
34
34
|
* synchronously has its result recorded first, so `handlerResults` still
|
|
35
35
|
* lists every handler that finished.
|
|
36
|
+
*
|
|
37
|
+
* The macrotask is a `setTimeout(…, 0)`, not `setImmediate`: the package is
|
|
38
|
+
* not Node-only, and browsers have no `setImmediate`, so an abort there
|
|
39
|
+
* threw a `ReferenceError`. A microtask would not do — the dispatch records
|
|
40
|
+
* a handler's result several promise hops after the handler returns.
|
|
36
41
|
*/
|
|
37
42
|
export declare function abortRejection(signal: AbortSignal, message: Message): AbortRejection;
|
|
38
43
|
//# sourceMappingURL=dispatcher.abort.d.ts.map
|
|
@@ -36,13 +36,18 @@ export function assertDispatchNotAborted(signal, message) {
|
|
|
36
36
|
* The rejection waits one macrotask. A handler that aborts and then returns
|
|
37
37
|
* synchronously has its result recorded first, so `handlerResults` still
|
|
38
38
|
* lists every handler that finished.
|
|
39
|
+
*
|
|
40
|
+
* The macrotask is a `setTimeout(…, 0)`, not `setImmediate`: the package is
|
|
41
|
+
* not Node-only, and browsers have no `setImmediate`, so an abort there
|
|
42
|
+
* threw a `ReferenceError`. A microtask would not do — the dispatch records
|
|
43
|
+
* a handler's result several promise hops after the handler returns.
|
|
39
44
|
*/
|
|
40
45
|
export function abortRejection(signal, message) {
|
|
41
46
|
let pending;
|
|
42
47
|
let onAbort;
|
|
43
48
|
const promise = new Promise((_resolve, reject) => {
|
|
44
49
|
onAbort = () => {
|
|
45
|
-
pending =
|
|
50
|
+
pending = setTimeout(() => reject(abortErrorFor(signal, message)), 0);
|
|
46
51
|
};
|
|
47
52
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
48
53
|
});
|
|
@@ -55,7 +60,7 @@ export function abortRejection(signal, message) {
|
|
|
55
60
|
if (onAbort)
|
|
56
61
|
signal.removeEventListener("abort", onAbort);
|
|
57
62
|
if (pending !== undefined)
|
|
58
|
-
|
|
63
|
+
clearTimeout(pending);
|
|
59
64
|
},
|
|
60
65
|
};
|
|
61
66
|
}
|
package/package.json
CHANGED