Skip to content

Commit bcde8d9

Browse files
committed
fix: add error handling to getChiaVersion and TLS override to fullNodeRpc
Restore try-catch in getChiaVersion so it is safe for callers outside of settle(). Add explicit NODE_TLS_REJECT_UNAUTHORIZED to fullNodeRpc.js so it does not rely on wallet.js import order as a side effect.
1 parent e4e12df commit bcde8d9

2 files changed

Lines changed: 17 additions & 10 deletions

File tree

src/datalayer/fullNodeRpc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import fs from 'fs';
1414
import path from 'path';
1515
import superagent from 'superagent';
1616

17+
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
18+
1719
import _ from 'lodash';
1820

1921
import { getChiaConfig } from './fullNode.js';

src/datalayer/wallet.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -333,18 +333,23 @@ const getChiaVersion = async () => {
333333
const url = `${rpcUrl}/get_version`;
334334
const { cert, key, timeout } = getBaseOptions();
335335

336-
const response = await superagent
337-
.post(url)
338-
.key(key)
339-
.cert(cert)
340-
.timeout(timeout)
341-
.send(JSON.stringify({}));
336+
try {
337+
const response = await superagent
338+
.post(url)
339+
.key(key)
340+
.cert(cert)
341+
.timeout(timeout)
342+
.send(JSON.stringify({}));
342343

343-
const data = response.body;
344-
if (data.success) {
345-
return data.version || null;
344+
const data = response.body;
345+
if (data.success) {
346+
return data.version || null;
347+
}
348+
return null;
349+
} catch (error) {
350+
logger.debug(`[diagnostics]: wallet get_version failed: ${error.message}`);
351+
return null;
346352
}
347-
return null;
348353
};
349354

350355
/**

0 commit comments

Comments
 (0)