Skip to content

Commit

Permalink
fix: prevent db closure during pinning
Browse files Browse the repository at this point in the history
  • Loading branch information
silkroadnomad committed Jan 20, 2025
1 parent 5a12146 commit 96cae27
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
2 changes: 1 addition & 1 deletion relay/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "libp2p-relay",
"version": "0.12.30",
"version": "0.12.31",
"private": true,
"scripts": {
"start:no-restart": "node src/relay.js",
Expand Down
12 changes: 2 additions & 10 deletions relay/src/pinner/pinningService.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export class PinningService {
* @returns {Promise<Object>} - Pinning result
*/
async pinContent(cid, durationMonths, nameOp) {
if(!this.db) await this.initializeDatabase()
return this.queue.add(async () => {
try {
const paymentStartDate = new Date(
Expand Down Expand Up @@ -218,16 +219,7 @@ export class PinningService {
} catch (error) {
logger.error(`Error pinning content ${cid}:`, error);
throw error;
} finally {
if (this.db) {
try {
await this.db.close();
logger.info('Database closed successfully');
} catch (closeError) {
logger.error('Error closing database:', closeError);
}
}
}
}
});
}

Expand Down

0 comments on commit 96cae27

Please sign in to comment.