Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix(network): invalidate interceptor pipe on disposal (#7761)
Lucien82efeae656c4
diff --git a/packages/network/src/services/http/__tests__/http.service.spec.ts b/packages/network/src/services/http/__tests__/http.service.spec.tsindex 7cf892d710..cba6f0a7f9 100644--- a/packages/network/src/services/http/__tests__/http.service.spec.ts+++ b/packages/network/src/services/http/__tests__/http.service.spec.ts@@ -130,6 +130,42 @@ describe('test "HTTPService"', () => {await expect(secondRequest).resolves.toMatchObject({ body: { step: 2 } });});+ it('stops invoking an interceptor after its registration is disposed', async () => {+ const interceptedUrls: string[] = [];+ const registration = httpService.registerHTTPInterceptor({+ interceptor: (request, next) => {+ interceptedUrls.push(request.url);+ return next(request);+ },+ });++ const firstSentRequestPromise = firstValueFrom(httpImplementation.newRequest$);+ const firstRequest = httpService.get('http://example.com/first');+ const firstSentRequest = await firstSentRequestPromise;+ httpImplementation.getHandler(firstSentRequest.uid).emitResponse(new HTTPResponse({+ headers: new HTTPHeaders(),+ status: 200,+ statusText: 'OK',+ body: null,+ }));+ await firstRequest;++ registration.dispose();++ const secondSentRequestPromise = firstValueFrom(httpImplementation.newRequest$);+ const secondRequest = httpService.get('http://example.com/second');+ const secondSentRequest = await secondSentRequestPromise;+ httpImplementation.getHandler(secondSentRequest.uid).emitResponse(new HTTPResponse({+ headers: new HTTPHeaders(),+ status: 200,+ statusText: 'OK',+ body: null,+ }));+ await secondRequest;++ expect(interceptedUrls).toEqual(['http://example.com/first']);+ });+it('streams progress events before the final response', async () => {const sentRequestPromise = firstValueFrom(httpImplementation.newRequest$);const eventsPromise = firstValueFrom(httpService.stream<string>('GET', 'http://example.com/sse'));diff --git a/packages/network/src/services/http/http.service.ts b/packages/network/src/services/http/http.service.tsindex 95a5798911..aef3c7b340 100644--- a/packages/network/src/services/http/http.service.ts+++ b/packages/network/src/services/http/http.service.ts@@ -97,7 +97,10 @@ export class HTTPService extends Disposable {this._pipe = null;- return toDisposable(() => remove(this._interceptors, interceptor));+ return toDisposable(() => {+ remove(this._interceptors, interceptor);+ this._pipe = null;+ });}get<T>(url: string, params?: IRequestParams): Promise<HTTPResponse<T>> {