Skip to content
This repository was archived by the owner on Feb 5, 2026. It is now read-only.

Commit 2556be6

Browse files
authored
BE-853 Resolve race condition of discovery request (#212)
Signed-off-by: Atsushi Neki <nekiaiken@gmail.com>
1 parent d9f846d commit 2556be6

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

app/platform/fabric/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"network-configs": {
33
"test-network": {
44
"name": "Test Network",
5-
"profile": "./connection-profile/test-network-ca.json"
5+
"profile": "./connection-profile/test-network.json"
66
}
77
},
88
"license": "Apache-2.0"

app/platform/fabric/gateway/FabricGateway.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export class FabricGateway {
5656
this.asLocalhost = false;
5757
this.ds = null;
5858
this.dsTargets = [];
59+
this.waitingResp = false;
5960
}
6061

6162
async initialize() {
@@ -432,6 +433,7 @@ export class FabricGateway {
432433
try {
433434
if (!this.waitingResp) {
434435
this.waitingResp = true;
436+
logger.info('Sending discovery request...');
435437
await this.ds.send({
436438
asLocalhost: this.asLocalhost,
437439
requestTimeout: 5000,
@@ -441,18 +443,18 @@ export class FabricGateway {
441443
logger.info('Succeeded to send discovery request');
442444
} else {
443445
logger.info('Have already been sending a request');
446+
return null;
444447
}
445448

446449
result = await this.ds.getDiscoveryResults(true);
450+
this.waitingResp = false;
447451
} catch (error) {
448452
logger.warn('Failed to send discovery request for channel', error);
449453
if (this.ds) {
450454
this.ds.close();
451455
this.ds = null;
452456
}
453457
result = null;
454-
} finally {
455-
this.waitingResp = false;
456458
}
457459
return result;
458460
}

app/test/FabricGateway.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function getFabricGatewayInstance() {
6767
const config = new FabricConfig();
6868
config.initialize('first-network', {
6969
name: 'My first network',
70-
profile: './connection-profile/first-network.json'
70+
profile: './connection-profile/test-network.json'
7171
});
7272
sinon.stub(config, 'getPeerTlsCACertsPem');
7373

app/test/SyncService.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function getSyncServicesInstance() {
5252
const config = new FabricConfig();
5353
config.initialize('first-network', {
5454
name: 'My first network',
55-
profile: './connection-profile/first-network.json'
55+
profile: './connection-profile/test-network.json'
5656
});
5757
sinon.stub(config, 'getPeerTlsCACertsPem');
5858
const stubGetCrudService = sinon.stub();

0 commit comments

Comments
 (0)