Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle pin claim job errors #676

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions src/modules/ipfs/pin.processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,18 @@ export class PinProcessor {
}

@OnQueueStalled()
onStalled(job: Job) {
this.logger.warn(`Stalled ${job.name} claim ${JSON.parse(job.data).cid}`);
onStalled(job: Job<PinClaimData>) {
this.logger.warn(`Stalled ${job.name} claim ${job.data.cid}`);
}

@OnQueueWaiting()
async OnQueueWaiting(job: Job) {
this.logger.debug(`Waiting ${job.name} claim ${job.data}`);
async OnQueueWaiting(jobId: number) {
this.logger.debug(`Waiting ${jobId}`);
}

@OnQueueFailed()
onFailed(job: Job, err: Error) {
this.logger.error(
`Failed ${job.name} claim ${JSON.parse(job.data).cid}: ${err}`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JGiter why removing the JSON.parse here? Is data an object type already?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, job.data is PinClaimData

);
onFailed(job: Job<PinClaimData>, err: Error) {
this.logger.error(`Failed ${job.name} claim ${job.data.cid}: ${err}`);
}

/**
Expand All @@ -56,14 +54,29 @@ export class PinProcessor {
async pin(job: Job<PinClaimData>) {
const cid = job.data.cid;
let claim = job.data.claim;
this.logger.debug(`Pinning CID ${cid}`);
try {
await this.didStoreCluster.get(cid);
} catch (_) {
if (!claim) {
claim = await this.didStoreInfura.get(cid);
try {
claim = await this.didStoreInfura.get(cid);
} catch (e) {
this.logger.error(
`Can not fetch claim from Infura IPFS. CID ${cid}: ${e}`
);
return;
}
}
try {
const clusterCid = await this.didStoreCluster.save(claim);
this.logger.debug(`CID ${cid} saved in cluster by CID ${clusterCid}`);
} catch (e) {
this.logger.error(
`Can not save claim in IPFS cluster. CID ${cid}: ${e}`
);
return;
}
const clusterCid = await this.didStoreCluster.save(claim);
this.logger.debug(`CID ${cid} saved in cluster by CID ${clusterCid}`);
}
}
}
Loading