diff --git a/backend/src/import-from-ss.js b/backend/src/import-from-ss.js index 72d4ef7..4eb5485 100644 --- a/backend/src/import-from-ss.js +++ b/backend/src/import-from-ss.js @@ -146,19 +146,23 @@ const importPaper = async (paper) => { const { paperId } = paper; const references = paper.references.filter((x) => !!x.paperId); const eachCitationWeightPercent = Math.floor(PPM_TO_CITATIONS / references.length); - const citations = await Promise.mapSeries( + const citations = (await Promise.mapSeries( references, async (citedPaper) => { // We need to fetch this paper so we can generate the post we WOULD add to the forum. // That way, if we later add the cited paper to the blockchain it will have the correct hash. // The forum allows dangling citations to support this use case. - const citedPost = await generatePost(citedPaper); - return { - weightPPM: eachCitationWeightPercent, - targetPostId: citedPost.hash, - }; + try { + const citedPost = await generatePost(citedPaper); + return { + weightPPM: eachCitationWeightPercent, + targetPostId: citedPost.hash, + }; + } catch (e) { + return null; + } }, - ); + )).filter((x) => !!x); // Make sure citation weights sum to the designated total if (citations.length) {