Skip to content

Commit ff66fc6

Browse files
FABN-1582: Fix leakage of Gateway confguration settings (#259)
Certain configuration settings could end up sharing objects between multiple Gateway instances, so connection options supplied to one Gateway connection could modify the connection options of other Gateway instances or the defaults. Signed-off-by: Mark S. Lewis <[email protected]>
1 parent d73d1a6 commit ff66fc6

File tree

3 files changed

+34
-39
lines changed

3 files changed

+34
-39
lines changed

fabric-network/src/gateway.ts

+17-17
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,6 @@ export interface DefaultQueryHandlerOptions {
5757
timeout?: number;
5858
}
5959

60-
const defaultOptions = Object.freeze({
61-
queryHandlerOptions: {
62-
timeout: 30, // 30 seconds
63-
strategy: QueryStrategies.MSPID_SCOPE_SINGLE
64-
},
65-
eventHandlerOptions: {
66-
endorseTimeout: 30, // 30 seconds
67-
commitTimeout: 300, // 5 minutes
68-
strategy: EventStrategies.MSPID_SCOPE_ALLFORTX
69-
},
70-
discovery: {
71-
enabled: true,
72-
asLocalhost: true
73-
}
74-
});
75-
7660
export function mergeOptions<B, E>(currentOptions: B, additionalOptions: E): B & E {
7761
const result = currentOptions as B & E;
7862
for (const prop in additionalOptions) {
@@ -273,7 +257,23 @@ export class Gateway {
273257
const method = 'connect';
274258
logger.debug('%s - start', method);
275259

276-
this.options = mergeOptions(mergeOptions({}, defaultOptions), options);
260+
const defaultOptions = {
261+
queryHandlerOptions: {
262+
timeout: 30, // 30 seconds
263+
strategy: QueryStrategies.MSPID_SCOPE_SINGLE
264+
},
265+
eventHandlerOptions: {
266+
endorseTimeout: 30, // 30 seconds
267+
commitTimeout: 300, // 5 minutes
268+
strategy: EventStrategies.MSPID_SCOPE_ALLFORTX
269+
},
270+
discovery: {
271+
enabled: true,
272+
asLocalhost: true
273+
}
274+
};
275+
276+
this.options = mergeOptions(defaultOptions, options);
277277
logger.debug('connection options: %j', options);
278278

279279
let loadCcp = false;

package-lock.json

+15-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@
6161
"elliptic": "^6.3.2",
6262
"eslint": "^6.8.0",
6363
"fabric-ca-client": "file:./fabric-ca-client",
64-
"fabric-client": "^1.4.8",
64+
"fabric-client": "^1.4.9",
6565
"fabric-common": "file:./fabric-common",
6666
"fabric-network": "file:./fabric-network",
6767
"fabric-protos": "file:./fabric-protos",
6868
"ink-docstrap": "^1.3.2",
6969
"jsdoc": "^3.6.3",
70-
"jsrsasign": "^8.0.15",
70+
"jsrsasign": "^8.0.19",
7171
"mocha": "^7.1.2",
7272
"nano": "^8.2.2",
7373
"npm-run-all": "^4.1.5",

0 commit comments

Comments
 (0)