Skip to content

Commit

Permalink
Merge pull request #162 from hypersign-protocol/fix-race-mongo
Browse files Browse the repository at this point in the history
Fix race mongo
  • Loading branch information
Pratap2018 authored Nov 25, 2024
2 parents 6b8efc2 + bae512a commit 5b806d8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"@nestjs/config": "^2.2.0",
"@nestjs/core": "^9.0.0",
"@nestjs/jwt": "^10.0.1",
"node-cache": "^5.1.2",
"@nestjs/mongoose": "^9.2.1",
"@nestjs/passport": "^9.0.0",
"@nestjs/platform-express": "^9.0.0",
Expand Down
35 changes: 25 additions & 10 deletions src/tx-send-module/tx-send-module.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,32 @@ export class TxSendModuleService {
}

async connect() {
Logger.log('Connecting Rabbit');
const connection = await amqp.connect(
this.configService.get('RABBIT_MQ_URI'),
);
this.channel = await connection.createChannel();
const { address: granterAddress } =
await this.hidWalletService.generateWallet(
this.configService.get('MNEMONIC'),
try {
Logger.log('Connecting Rabbit');
const connection = await amqp.connect(
this.configService.get('RABBIT_MQ_URI'),
);
this.granterAddress = granterAddress;
Logger.log('Connected Rabbit');
connection.on('error', (err) => {
console.error('Connection error:', err);
});

connection.on('close', () => {
Logger.error('Connection closed, reconnecting...', 'RabbitMQ');
});
this.channel = await connection.createChannel();
this.channel.on('error', (err) => {
Logger.error(err, 'RabbitMQ');
});

const { address: granterAddress } =
await this.hidWalletService.generateWallet(
this.configService.get('MNEMONIC'),
);
this.granterAddress = granterAddress;
Logger.log('Connected Rabbit');
} catch (error) {
Logger.error(error, 'RabbitMQ');
}
}

async prepareRegisterCredentialStatus(
Expand Down

0 comments on commit 5b806d8

Please sign in to comment.