Skip to content

Commit c52a41f

Browse files
authored
Change clean resources task to start always (#612)
1 parent 9c1c2d1 commit c52a41f

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/invocation/InvocationService.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ export class InvocationService {
291291
if (this.backupAckToClientEnabled) {
292292
const listenerService = this.client.getListenerService();
293293
listenerService.registerListener(backupListenerCodec, this.backupEventHandler.bind(this));
294-
this.cleanResourcesTask = this.scheduleCleanResourcesTask(this.cleanResourcesMillis);
295294
}
295+
this.cleanResourcesTask = this.scheduleCleanResourcesTask(this.cleanResourcesMillis);
296296
}
297297

298298
private scheduleCleanResourcesTask(periodMillis: number): Task {
@@ -306,7 +306,9 @@ export class InvocationService {
306306
this.notifyError(invocation, new TargetDisconnectedError(connection.getClosedReason()));
307307
continue;
308308
}
309-
invocation.detectAndHandleBackupTimeout(this.operationBackupTimeoutMillis);
309+
if (this.backupAckToClientEnabled) {
310+
invocation.detectAndHandleBackupTimeout(this.operationBackupTimeoutMillis);
311+
}
310312
}
311313
}, periodMillis, periodMillis);
312314
}
@@ -316,7 +318,7 @@ export class InvocationService {
316318
return;
317319
}
318320
this.isShutdown = true;
319-
if (this.cleanResourcesTask != null) {
321+
if (this.cleanResourcesTask !== undefined) {
320322
cancelRepetitionTask(this.cleanResourcesTask);
321323
}
322324
for (const invocation of this.pending.values()) {

test/invocation/InvocationServiceTest.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,27 +92,27 @@ describe('InvocationServiceTest', function () {
9292
expect(client.getListenerService().registerListener.calledOnce).to.be.true;
9393
});
9494

95-
it('should not start clean resource task and register listener when client is unisocket', function () {
95+
it('should start clean resource task without listener registration when client is unisocket', function () {
9696
const config = new ClientConfigImpl();
9797
config.network.smartRouting = false;
9898
const client = mockClient(config);
9999

100100
service = new InvocationService(client);
101101
service.start();
102102

103-
expect(service.cleanResourcesTask).to.be.undefined;
103+
expect(service.cleanResourcesTask).to.be.not.undefined;
104104
expect(client.getListenerService().registerListener.notCalled).to.be.true;
105105
});
106106

107-
it('should not start clean resource task and register listener when acks are disabled', function () {
107+
it('should start clean resource task without listener registration when acks are disabled', function () {
108108
const config = new ClientConfigImpl();
109109
config.backupAckToClientEnabled = false;
110110
const client = mockClient(config);
111111

112112
service = new InvocationService(client);
113113
service.start();
114114

115-
expect(service.cleanResourcesTask).to.be.undefined;
115+
expect(service.cleanResourcesTask).to.be.not.undefined;
116116
expect(client.getListenerService().registerListener.notCalled).to.be.true;
117117
});
118118

0 commit comments

Comments
 (0)