diff --git a/src/invocation/InvocationService.ts b/src/invocation/InvocationService.ts index e03ca58e5..b3ac72ab9 100644 --- a/src/invocation/InvocationService.ts +++ b/src/invocation/InvocationService.ts @@ -291,8 +291,8 @@ export class InvocationService { if (this.backupAckToClientEnabled) { const listenerService = this.client.getListenerService(); listenerService.registerListener(backupListenerCodec, this.backupEventHandler.bind(this)); - this.cleanResourcesTask = this.scheduleCleanResourcesTask(this.cleanResourcesMillis); } + this.cleanResourcesTask = this.scheduleCleanResourcesTask(this.cleanResourcesMillis); } private scheduleCleanResourcesTask(periodMillis: number): Task { @@ -306,7 +306,9 @@ export class InvocationService { this.notifyError(invocation, new TargetDisconnectedError(connection.getClosedReason())); continue; } - invocation.detectAndHandleBackupTimeout(this.operationBackupTimeoutMillis); + if (this.backupAckToClientEnabled) { + invocation.detectAndHandleBackupTimeout(this.operationBackupTimeoutMillis); + } } }, periodMillis, periodMillis); } @@ -316,7 +318,7 @@ export class InvocationService { return; } this.isShutdown = true; - if (this.cleanResourcesTask != null) { + if (this.cleanResourcesTask !== undefined) { cancelRepetitionTask(this.cleanResourcesTask); } for (const invocation of this.pending.values()) { diff --git a/test/invocation/InvocationServiceTest.js b/test/invocation/InvocationServiceTest.js index 5b442129b..fda190227 100644 --- a/test/invocation/InvocationServiceTest.js +++ b/test/invocation/InvocationServiceTest.js @@ -92,7 +92,7 @@ describe('InvocationServiceTest', function () { expect(client.getListenerService().registerListener.calledOnce).to.be.true; }); - it('should not start clean resource task and register listener when client is unisocket', function () { + it('should start clean resource task without listener registration when client is unisocket', function () { const config = new ClientConfigImpl(); config.network.smartRouting = false; const client = mockClient(config); @@ -100,11 +100,11 @@ describe('InvocationServiceTest', function () { service = new InvocationService(client); service.start(); - expect(service.cleanResourcesTask).to.be.undefined; + expect(service.cleanResourcesTask).to.be.not.undefined; expect(client.getListenerService().registerListener.notCalled).to.be.true; }); - it('should not start clean resource task and register listener when acks are disabled', function () { + it('should start clean resource task without listener registration when acks are disabled', function () { const config = new ClientConfigImpl(); config.backupAckToClientEnabled = false; const client = mockClient(config); @@ -112,7 +112,7 @@ describe('InvocationServiceTest', function () { service = new InvocationService(client); service.start(); - expect(service.cleanResourcesTask).to.be.undefined; + expect(service.cleanResourcesTask).to.be.not.undefined; expect(client.getListenerService().registerListener.notCalled).to.be.true; });