Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
serverExternalPackages: ['pdf-parse', '@napi-rs/canvas'],
images: {
qualities: [75, 90, 100],
remotePatterns: [
Expand Down
6 changes: 5 additions & 1 deletion src/app/api/uploadthing/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import { Document } from '@langchain/core/documents';
import { PineconeStore } from '@langchain/pinecone';
import { RecursiveCharacterTextSplitter } from '@langchain/textsplitters';
import { CanvasFactory } from 'pdf-parse/worker';
import { PDFParse } from 'pdf-parse';

Check failure on line 6 in src/app/api/uploadthing/core.ts

View workflow job for this annotation

GitHub Actions / ESLint & Prettier

`pdf-parse` import should occur before import of `pdf-parse/worker`
import { createUploadthing, type FileRouter } from 'uploadthing/next';
import { UploadThingError } from 'uploadthing/server';

Expand Down Expand Up @@ -40,6 +41,7 @@

const parser = new PDFParse({
data: new Uint8Array(await response.arrayBuffer()),
CanvasFactory,
});
const parsedPdf = await parser
.getText()
Expand Down Expand Up @@ -82,7 +84,9 @@
id: createdFile.id,
},
});
} catch {
} catch (error) {
console.error('PDF processing failed:', error);

await db.file.update({
data: {
uploadStatus: 'FAILED',
Expand Down
Loading