@zimic/interceptor 1.2.3-canary.0 → 1.2.3-canary.2
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/{chunk-ZPZDEDJI.mjs → chunk-XCYZ5L2M.mjs} +9 -4
- package/dist/{chunk-ZPZDEDJI.mjs.map → chunk-XCYZ5L2M.mjs.map} +1 -1
- package/dist/{chunk-EMX4G67A.js → chunk-ZU6IGW27.js} +9 -4
- package/dist/{chunk-EMX4G67A.js.map → chunk-ZU6IGW27.js.map} +1 -1
- package/dist/cli.js +18 -18
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +2 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/http.js +40 -23
- package/dist/http.js.map +1 -1
- package/dist/http.mjs +40 -23
- package/dist/http.mjs.map +1 -1
- package/dist/server.js +6 -6
- package/dist/server.mjs +1 -1
- package/package.json +5 -5
- package/src/http/interceptor/HttpInterceptorClient.ts +5 -9
- package/src/http/interceptor/LocalHttpInterceptor.ts +1 -1
- package/src/http/interceptor/RemoteHttpInterceptor.ts +1 -6
- package/src/http/interceptorWorker/RemoteHttpInterceptorWorker.ts +47 -8
- package/src/server/InterceptorServer.ts +7 -2
package/dist/http.mjs
CHANGED
|
@@ -1635,21 +1635,18 @@ var HttpInterceptorClient = class {
|
|
|
1635
1635
|
}
|
|
1636
1636
|
}
|
|
1637
1637
|
}
|
|
1638
|
-
clear(
|
|
1639
|
-
const
|
|
1638
|
+
clear() {
|
|
1639
|
+
const clearPromises = [
|
|
1640
1640
|
Promise.resolve(this.workerOrThrow.clearInterceptorHandlers(this))
|
|
1641
1641
|
];
|
|
1642
1642
|
for (const method of HTTP_METHODS) {
|
|
1643
|
-
const
|
|
1644
|
-
|
|
1645
|
-
clearResults.push(Promise.resolve(result));
|
|
1643
|
+
for (const result of this.clearMethodHandlers(method)) {
|
|
1644
|
+
clearPromises.push(Promise.resolve(result));
|
|
1646
1645
|
}
|
|
1647
1646
|
const pathHandlers = this.handlers[method];
|
|
1648
1647
|
pathHandlers.clear();
|
|
1649
1648
|
}
|
|
1650
|
-
|
|
1651
|
-
void Promise.all(clearResults).then(options.onCommitSuccess, options.onCommitError);
|
|
1652
|
-
}
|
|
1649
|
+
return Promise.all(clearPromises);
|
|
1653
1650
|
}
|
|
1654
1651
|
clearMethodHandlers(method) {
|
|
1655
1652
|
const pathHandlers = this.handlers[method];
|
|
@@ -2440,8 +2437,16 @@ var RemoteHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
|
2440
2437
|
throw new NotRunningHttpInterceptorError_default();
|
|
2441
2438
|
}
|
|
2442
2439
|
this.httpHandlers.clear();
|
|
2443
|
-
if (this.webSocketClient.isRunning) {
|
|
2440
|
+
if (!this.webSocketClient.isRunning) {
|
|
2441
|
+
return;
|
|
2442
|
+
}
|
|
2443
|
+
try {
|
|
2444
2444
|
await this.webSocketClient.request("interceptors/workers/reset", void 0);
|
|
2445
|
+
} catch (error) {
|
|
2446
|
+
const isMessageAbortError = error instanceof WebSocketMessageAbortError;
|
|
2447
|
+
if (!isMessageAbortError) {
|
|
2448
|
+
throw error;
|
|
2449
|
+
}
|
|
2445
2450
|
}
|
|
2446
2451
|
}
|
|
2447
2452
|
async clearInterceptorHandlers(interceptor) {
|
|
@@ -2453,14 +2458,22 @@ var RemoteHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
|
2453
2458
|
this.httpHandlers.delete(handler.id);
|
|
2454
2459
|
}
|
|
2455
2460
|
}
|
|
2456
|
-
if (this.webSocketClient.isRunning) {
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2461
|
+
if (!this.webSocketClient.isRunning) {
|
|
2462
|
+
return;
|
|
2463
|
+
}
|
|
2464
|
+
const groupsToRecommit = Array.from(this.httpHandlers.values(), (handler) => ({
|
|
2465
|
+
id: handler.id,
|
|
2466
|
+
baseURL: handler.baseURL,
|
|
2467
|
+
method: handler.method,
|
|
2468
|
+
path: handler.path
|
|
2469
|
+
}));
|
|
2470
|
+
try {
|
|
2463
2471
|
await this.webSocketClient.request("interceptors/workers/reset", groupsToRecommit);
|
|
2472
|
+
} catch (error) {
|
|
2473
|
+
const isMessageAbortError = error instanceof WebSocketMessageAbortError;
|
|
2474
|
+
if (!isMessageAbortError) {
|
|
2475
|
+
throw error;
|
|
2476
|
+
}
|
|
2464
2477
|
}
|
|
2465
2478
|
}
|
|
2466
2479
|
get interceptorsWithHandlers() {
|
|
@@ -2640,7 +2653,7 @@ var LocalHttpInterceptor = class {
|
|
|
2640
2653
|
this.client.checkTimes();
|
|
2641
2654
|
}
|
|
2642
2655
|
clear() {
|
|
2643
|
-
this.client.clear();
|
|
2656
|
+
void this.client.clear();
|
|
2644
2657
|
}
|
|
2645
2658
|
};
|
|
2646
2659
|
var LocalHttpInterceptor_default = LocalHttpInterceptor;
|
|
@@ -2763,12 +2776,7 @@ var RemoteHttpInterceptor = class {
|
|
|
2763
2776
|
});
|
|
2764
2777
|
}
|
|
2765
2778
|
async clear() {
|
|
2766
|
-
await
|
|
2767
|
-
this.client.clear({
|
|
2768
|
-
onCommitSuccess: resolve,
|
|
2769
|
-
onCommitError: reject
|
|
2770
|
-
});
|
|
2771
|
-
});
|
|
2779
|
+
await this.client.clear();
|
|
2772
2780
|
}
|
|
2773
2781
|
};
|
|
2774
2782
|
var RemoteHttpInterceptor_default = RemoteHttpInterceptor;
|
|
@@ -2813,6 +2821,15 @@ var InvalidJSONError = class extends InvalidJSONError$1 {
|
|
|
2813
2821
|
/* istanbul ignore next -- @preserve
|
|
2814
2822
|
* Reply listeners are always present when notified in normal conditions. If they were not present, the request
|
|
2815
2823
|
* would reach a timeout and not be responded. The empty set serves as a fallback. */
|
|
2824
|
+
/* istanbul ignore next -- @preserve
|
|
2825
|
+
*
|
|
2826
|
+
* If the socket is closed before receiving a response, the message is aborted with an error. This can happen if
|
|
2827
|
+
* we send a request message and the interceptor server closes the socket before sending a response. In this case,
|
|
2828
|
+
* we can safely ignore the error because we know that the server is shutting down and resetting is no longer
|
|
2829
|
+
* necessary.
|
|
2830
|
+
*
|
|
2831
|
+
* Due to the rare nature of this edge case, we can't reliably reproduce it in tests. */
|
|
2832
|
+
/* istanbul ignore next -- @preserve */
|
|
2816
2833
|
|
|
2817
2834
|
export { DisabledRequestSavingError_default as DisabledRequestSavingError, InvalidFormDataError, InvalidJSONError, NotRunningHttpInterceptorError_default as NotRunningHttpInterceptorError, RequestSavingSafeLimitExceededError_default as RequestSavingSafeLimitExceededError, RunningHttpInterceptorError_default as RunningHttpInterceptorError, TimesCheckError_default as TimesCheckError, UnknownHttpInterceptorPlatformError_default as UnknownHttpInterceptorPlatformError, UnknownHttpInterceptorTypeError_default as UnknownHttpInterceptorTypeError, UnregisteredBrowserServiceWorkerError_default as UnregisteredBrowserServiceWorkerError, createHttpInterceptor };
|
|
2818
2835
|
//# sourceMappingURL=http.mjs.map
|