diff --git a/src/lib/notion/client.ts b/src/lib/notion/client.ts index 1b58a926d..32f5fb252 100644 --- a/src/lib/notion/client.ts +++ b/src/lib/notion/client.ts @@ -1,4 +1,5 @@ import fs, { createWriteStream } from 'node:fs' +import { pipeline } from 'node:stream/promises' import axios, { AxiosResponse } from 'axios' import sharp from 'sharp' import retry from 'async-retry' @@ -410,7 +411,13 @@ export async function downloadFile(url: URL) { if (res.headers['content-type'] === 'image/jpeg') { stream = stream.pipe(rotate) } - return stream.pipe(new ExifTransformer()).pipe(writeStream) + try { + return pipeline(stream, new ExifTransformer(), writeStream) + } catch (err) { + console.log(err) + writeStream.end() + return Promise.resolve() + } } export async function getDatabase(): Promise {