@opentap/runner-client 4.1.0 → 4.2.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/dist/cjs/BaseClient.js +8 -3
- package/dist/mjs/BaseClient.js +6 -3
- package/package.json +1 -1
package/dist/cjs/BaseClient.js
CHANGED
|
@@ -102,8 +102,13 @@ var BaseClient = /** @class */ (function () {
|
|
|
102
102
|
enumerable: false,
|
|
103
103
|
configurable: true
|
|
104
104
|
});
|
|
105
|
-
BaseClient.prototype.withTimeout = function (promise, timeout) {
|
|
106
|
-
return Promise.race([
|
|
105
|
+
BaseClient.prototype.withTimeout = function (promise, timeout, subject) {
|
|
106
|
+
return Promise.race([
|
|
107
|
+
promise,
|
|
108
|
+
new Promise(function (_, reject) {
|
|
109
|
+
return setTimeout(function () { return reject(new Error("".concat(nats_ws_1.ErrorCode.Timeout, ": '").concat(subject, "' timed out after ").concat(timeout, "ms"))); }, timeout);
|
|
110
|
+
}),
|
|
111
|
+
]);
|
|
107
112
|
};
|
|
108
113
|
/**
|
|
109
114
|
* Send a request to the nats server.
|
|
@@ -223,7 +228,7 @@ var BaseClient = /** @class */ (function () {
|
|
|
223
228
|
this.connection.publish(subject, nats_ws_1.Empty, opts);
|
|
224
229
|
}
|
|
225
230
|
// Now that we have sent the terminating chunk, the result should arrive on our promise.
|
|
226
|
-
return [2 /*return*/, this.withTimeout(responsePromise, timeout).catch(function (err) {
|
|
231
|
+
return [2 /*return*/, this.withTimeout(responsePromise, timeout, subject).catch(function (err) {
|
|
227
232
|
subscription.unsubscribe();
|
|
228
233
|
return Promise.reject(_this.natsErrorHandler(err, subject));
|
|
229
234
|
})];
|
package/dist/mjs/BaseClient.js
CHANGED
|
@@ -49,8 +49,11 @@ export class BaseClient {
|
|
|
49
49
|
this.connectionOptions.timeout = (options === null || options === void 0 ? void 0 : options.timeout) || DEFAULT_TIMEOUT;
|
|
50
50
|
this.eventEmitter = new EventEmitter();
|
|
51
51
|
}
|
|
52
|
-
withTimeout(promise, timeout) {
|
|
53
|
-
return Promise.race([
|
|
52
|
+
withTimeout(promise, timeout, subject) {
|
|
53
|
+
return Promise.race([
|
|
54
|
+
promise,
|
|
55
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error(`${ErrorCode.Timeout}: '${subject}' timed out after ${timeout}ms`)), timeout)),
|
|
56
|
+
]);
|
|
54
57
|
}
|
|
55
58
|
/**
|
|
56
59
|
* Send a request to the nats server.
|
|
@@ -178,7 +181,7 @@ export class BaseClient {
|
|
|
178
181
|
this.connection.publish(subject, Empty, opts);
|
|
179
182
|
}
|
|
180
183
|
// Now that we have sent the terminating chunk, the result should arrive on our promise.
|
|
181
|
-
return this.withTimeout(responsePromise, timeout).catch(err => {
|
|
184
|
+
return this.withTimeout(responsePromise, timeout, subject).catch(err => {
|
|
182
185
|
subscription.unsubscribe();
|
|
183
186
|
return Promise.reject(this.natsErrorHandler(err, subject));
|
|
184
187
|
});
|