diff --git a/apps/api/src/lib/html-to-markdown.ts b/apps/api/src/lib/html-to-markdown.ts
index 8800d916..92bcd4cd 100644
--- a/apps/api/src/lib/html-to-markdown.ts
+++ b/apps/api/src/lib/html-to-markdown.ts
@@ -6,22 +6,28 @@ import * as Sentry from "@sentry/node";
import dotenv from 'dotenv';
import { logger } from './logger';
+import { stat } from 'fs/promises';
dotenv.config();
// TODO: add a timeout to the Go parser
+const goExecutablePath = join(process.cwd(), 'sharedLibs', 'go-html-to-md', 'html-to-markdown.so');
class GoMarkdownConverter {
private static instance: GoMarkdownConverter;
private convert: any;
private constructor() {
- const goExecutablePath = join(process.cwd(), 'sharedLibs', 'go-html-to-md', 'html-to-markdown.so');
const lib = koffi.load(goExecutablePath);
this.convert = lib.func('ConvertHTMLToMarkdown', 'string', ['string']);
}
- public static getInstance(): GoMarkdownConverter {
+ public static async getInstance(): Promise {
if (!GoMarkdownConverter.instance) {
+ try {
+ await stat(goExecutablePath);
+ } catch (_) {
+ throw Error("Go shared library not found");
+ }
GoMarkdownConverter.instance = new GoMarkdownConverter();
}
return GoMarkdownConverter.instance;
@@ -47,7 +53,7 @@ export async function parseMarkdown(html: string | null | undefined): Promise