@@ -212,7 +212,12 @@ export abstract class Client<O extends ClientOptions = ClientOptions> {
212212
213213 protected _promiseBuffer : PromiseBuffer < unknown > ;
214214
215- /** Cleanup functions to call on dispose */
215+ /**
216+ * Cleanup functions to call on dispose.
217+ *
218+ * NOTE: These callbacks are only invoked by subclasses whose `dispose()` implementation runs them
219+ * (currently only `ServerRuntimeClient`). The base `Client.dispose()` is a no-op and will not run them.
220+ */
216221 protected _disposeCallbacks : ( ( ) => void ) [ ] ;
217222
218223 /**
@@ -1176,6 +1181,11 @@ export abstract class Client<O extends ClientOptions = ClientOptions> {
11761181 /**
11771182 * Register a cleanup function to be called when the client is disposed.
11781183 * This is useful for integrations that need to clean up global state.
1184+ *
1185+ * NOTE: Registered callbacks are only executed by subclasses whose `dispose()` implementation
1186+ * runs them. At the moment that is only `ServerRuntimeClient` (and clients extending it). On the
1187+ * base `Client` (e.g. the browser client), `dispose()` is a no-op, so callbacks registered here
1188+ * will never be invoked.
11791189 */
11801190 public registerCleanup ( callback : ( ) => void ) : void {
11811191 this . _disposeCallbacks . push ( callback ) ;
@@ -1184,7 +1194,10 @@ export abstract class Client<O extends ClientOptions = ClientOptions> {
11841194 /**
11851195 * Disposes of the client and releases all resources.
11861196 *
1187- * Subclasses should override this method to clean up their own resources.
1197+ * Subclasses should override this method to clean up their own resources, including invoking
1198+ * any callbacks registered via {@link Client.registerCleanup}. The base implementation is a
1199+ * no-op and does NOT execute registered cleanup callbacks.
1200+ *
11881201 * After calling dispose(), the client should not be used anymore.
11891202 */
11901203 public dispose ( ) : void {
0 commit comments