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

fixed memory leak (#2831) (#2833) #2835

Merged
merged 1 commit into from
Nov 12, 2024
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
6 changes: 3 additions & 3 deletions apps/backoffice-v2/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import '@ballerine/ui/dist/style.css';
import '@fontsource/inter';

import { Toaster } from '@/common/components/organisms/Toaster/Toaster';
import { registerFont } from '@ballerine/react-pdf-toolkit';
import { Font } from '@react-pdf/renderer';
// Uncomment once react-pdf is back in use
// import { Font } from '@react-pdf/renderer';
import { Router } from './Router/Router';
import { env } from './common/env/env';
import './i18n';
Expand All @@ -24,7 +24,7 @@ initializeSessionRecording();

dayjs.extend(advancedFormat);

registerFont(Font);
// registerFont(Font);

export const TOAST_DURATION_IN_MS = 1000 * 3;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export const CaseOptions = () => {
<DropdownMenuItem className="w-full px-8 py-1" asChild>
<Button
onClick={() => generateAndOpenPDFInNewTab()}
disabled={isGeneratingPDF}
// disabled={isGeneratingPDF}
disabled
variant={'ghost'}
className="justify-start"
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { TWorkflowById } from '@/domains/workflows/fetchers';
import { TCustomer } from '@/domains/customer/fetchers';
import { useMutation } from '@tanstack/react-query';
import { TitlePagePDF } from '@/pages/Entity/components/Case/components/CaseOptions/hooks/useCaseOptionsLogic/renderers/title-page.pdf';
import { RegistryPagePDF } from '@/pages/Entity/components/Case/components/CaseOptions/hooks/useCaseOptionsLogic/renderers/registry-page.pdf';
import { CompanyOwnershipPagePDF } from '@/pages/Entity/components/Case/components/CaseOptions/hooks/useCaseOptionsLogic/renderers/company-ownership-page.pdf';
import { CompanySanctionsPagePDF } from '@/pages/Entity/components/Case/components/CaseOptions/hooks/useCaseOptionsLogic/renderers/company-sanctions-page.pdf';
import { IdentityVerificationsPagePDF } from '@/pages/Entity/components/Case/components/CaseOptions/hooks/useCaseOptionsLogic/renderers/identity-verifications-page.pdf';
import { IndividualSantcionsPagePDF } from '@/pages/Entity/components/Case/components/CaseOptions/hooks/useCaseOptionsLogic/renderers/individual-sanctions-page.pdf';
import { Document, pdf } from '@react-pdf/renderer';
// import { TitlePagePDF } from '@/pages/Entity/components/Case/components/CaseOptions/hooks/useCaseOptionsLogic/renderers/title-page.pdf';
// import { RegistryPagePDF } from '@/pages/Entity/components/Case/components/CaseOptions/hooks/useCaseOptionsLogic/renderers/registry-page.pdf';
// import { CompanyOwnershipPagePDF } from '@/pages/Entity/components/Case/components/CaseOptions/hooks/useCaseOptionsLogic/renderers/company-ownership-page.pdf';
// import { CompanySanctionsPagePDF } from '@/pages/Entity/components/Case/components/CaseOptions/hooks/useCaseOptionsLogic/renderers/company-sanctions-page.pdf';
// import { IdentityVerificationsPagePDF } from '@/pages/Entity/components/Case/components/CaseOptions/hooks/useCaseOptionsLogic/renderers/identity-verifications-page.pdf';
// import { IndividualSantcionsPagePDF } from '@/pages/Entity/components/Case/components/CaseOptions/hooks/useCaseOptionsLogic/renderers/individual-sanctions-page.pdf';
// import { Document, pdf } from '@react-pdf/renderer';
import { toast } from 'sonner';
import { t } from 'i18next';

Expand All @@ -29,21 +29,22 @@ export const useGeneratePDFMutation = ({
customer: TCustomer;
}) => {
return useMutation({
// Temporarily disabled until react-pdf no longer has memory leaks
mutationFn: async () => {
const pdfs = [
TitlePagePDF,
RegistryPagePDF,
CompanyOwnershipPagePDF,
CompanySanctionsPagePDF,
IdentityVerificationsPagePDF,
IndividualSantcionsPagePDF,
];
const renderers = pdfs.map(PDF => new PDF(workflow, customer));
const pages = await Promise.all(renderers.map(renderer => renderer.render()));

const pdfBlob = await pdf(<Document>{pages}</Document>).toBlob();

openBlobInNewTab(pdfBlob);
// const pdfs = [
// TitlePagePDF,
// RegistryPagePDF,
// CompanyOwnershipPagePDF,
// CompanySanctionsPagePDF,
// IdentityVerificationsPagePDF,
// IndividualSantcionsPagePDF,
// ];
// const renderers = pdfs.map(PDF => new PDF(workflow, customer));
// const pages = await Promise.all(renderers.map(renderer => renderer.render()));
//
// const pdfBlob = await pdf(<Document>{pages}</Document>).toBlob();
//
// openBlobInNewTab(pdfBlob);
},
onError: error => {
console.error(`Failed to open PDF certificate: ${JSON.stringify(error)}`);
Expand Down
2 changes: 1 addition & 1 deletion services/workflows-service/prisma/data-migrations
Loading