[Bug] Disposed HTTP interceptors still run on subsequent requests
Before you submit this issue, have you checked the following options?
- Is this really a problem?
- I have searched the GitHub Issues for similar issues, but did not find anything.
Affected packages and versions
@univerjs/network 1.0.2 on dev at cfb245a2f.
Reproduction link
This is an HTTPService lifecycle issue. It can be reproduced using the repository's HTTP test fixture, which supplies a MockHTTPImplementation; a browser template is not needed. With an HTTPService whose implementation returns successful responses for both URLs:
const calls: string[] = [];
const registration = httpService.registerHTTPInterceptor({
interceptor: (request, next) => {
calls.push(request.url);
return next(request);
},
});
await httpService.get('http://example.com/first');
registration.dispose();
await httpService.get('http://example.com/second');
console.log(calls);The first request builds the cached interceptor pipeline before the registration is disposed.
Expected behavior
calls contains only ['http://example.com/first']. A disposed interceptor is not invoked for subsequent requests.
Actual behavior
calls contains both ['http://example.com/first', 'http://example.com/second']. The disposer removes the interceptor from _interceptors, but the cached _pipe still contains it. It stops running only after a later registration rebuilds the pipe.
System information
Reproduced in the repository's Vitest setup on Windows with Node.js v24.11.1 and pnpm 11.19.0.
The HTTP interceptor pipeline was introduced in #1664; this report concerns its disposal lifecycle.
Source: dream-num/univer