[PR #1287] [MERGED] fix: move sealing to a background job #1531

Closed
opened 2026-02-26 19:33:39 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/documenso/documenso/pull/1287
Author: @Mythie
Created: 8/13/2024
Status: Merged
Merged: 8/14/2024
Merged by: @Mythie

Base: mainHead: fix/move-sealing-to-background-job


📝 Commits (3)

📊 Changes

9 files changed (+326 additions, -23 deletions)

View changed files

📝 apps/web/src/app/(signing)/sign/[token]/complete/page.tsx (+3 -0)
apps/web/src/app/(signing)/sign/[token]/complete/poll-until-document-completed.tsx (+32 -0)
📝 packages/app-tests/e2e/document-flow/stepper-component.spec.ts (+17 -8)
📝 packages/lib/jobs/client.ts (+2 -0)
packages/lib/jobs/definitions/internal/seal-document.ts (+253 -0)
📝 packages/lib/server-only/document/complete-document-with-token.ts (+8 -6)
📝 packages/lib/server-only/document/seal-document.ts (+0 -4)
📝 packages/lib/server-only/document/send-document.tsx (+9 -4)
📝 packages/lib/server-only/htmltopdf/get-certificate-pdf.ts (+2 -1)

📄 Description

Description

When signing a document the final signer is often
greeted with a super long completing spinner since
we are synchronously signing the document and sending
emails to all recipients. This is frustrating and
has caused issues for customers and self-hosters.

Moving sealing to a background job resolves this
and improves the overall snappiness of the app while
also supporting retrying the sealing if it were to
fail in the future.

This has the implication of a document no longer
immediately being in a "completed" state once all
signers have signed. To assist with this we now
refetch the page every 5 seconds upon signing
completion until the document status as shifted to
completed.

N/A

Changes Made

  • Moved the sealing of documents to a background job

Testing Performed

  • Signed a document as per usual and verified that the background job was triggered and completed successfully
  • Verified that the final document has all the fields and other items attached to it

Summary by CodeRabbit

  • New Features

    • Introduced a PollUntilDocumentCompleted component for real-time monitoring of document signing status.
    • Added job processing for sealing documents, enhancing the document management system's capabilities.
  • Bug Fixes

    • Improved error handling and logging during document sealing operations through the new job architecture.
  • Refactor

    • Transitioned from direct function calls for sealing documents to a job-triggering mechanism, promoting asynchronous processing and better scalability.
  • Tests

    • Enhanced test cases for improved structure and assertions, ensuring better reliability in document signing verification and date validation.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/documenso/documenso/pull/1287 **Author:** [@Mythie](https://github.com/Mythie) **Created:** 8/13/2024 **Status:** ✅ Merged **Merged:** 8/14/2024 **Merged by:** [@Mythie](https://github.com/Mythie) **Base:** `main` ← **Head:** `fix/move-sealing-to-background-job` --- ### 📝 Commits (3) - [`ff4de44`](https://github.com/documenso/documenso/commit/ff4de443e1a7877f50f5735f8f8075ebe55ce5be) fix: move sealing to a background job - [`41a36cf`](https://github.com/documenso/documenso/commit/41a36cf70df70024d8a5d2962caa9da6faac07e2) fix: build errors - [`0a97e80`](https://github.com/documenso/documenso/commit/0a97e809f1076f6d1f8c2ab9704bb227b14b2962) fix: update tests ### 📊 Changes **9 files changed** (+326 additions, -23 deletions) <details> <summary>View changed files</summary> 📝 `apps/web/src/app/(signing)/sign/[token]/complete/page.tsx` (+3 -0) ➕ `apps/web/src/app/(signing)/sign/[token]/complete/poll-until-document-completed.tsx` (+32 -0) 📝 `packages/app-tests/e2e/document-flow/stepper-component.spec.ts` (+17 -8) 📝 `packages/lib/jobs/client.ts` (+2 -0) ➕ `packages/lib/jobs/definitions/internal/seal-document.ts` (+253 -0) 📝 `packages/lib/server-only/document/complete-document-with-token.ts` (+8 -6) 📝 `packages/lib/server-only/document/seal-document.ts` (+0 -4) 📝 `packages/lib/server-only/document/send-document.tsx` (+9 -4) 📝 `packages/lib/server-only/htmltopdf/get-certificate-pdf.ts` (+2 -1) </details> ### 📄 Description ## Description When signing a document the final signer is often greeted with a super long completing spinner since we are synchronously signing the document and sending emails to all recipients. This is frustrating and has caused issues for customers and self-hosters. Moving sealing to a background job resolves this and improves the overall snappiness of the app while also supporting retrying the sealing if it were to fail in the future. This has the implication of a document no longer immediately being in a "completed" state once all signers have signed. To assist with this we now refetch the page every 5 seconds upon signing completion until the document status as shifted to completed. ## Related Issue N/A ## Changes Made - Moved the sealing of documents to a background job ## Testing Performed - Signed a document as per usual and verified that the background job was triggered and completed successfully - Verified that the final document has all the fields and other items attached to it <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a `PollUntilDocumentCompleted` component for real-time monitoring of document signing status. - Added job processing for sealing documents, enhancing the document management system's capabilities. - **Bug Fixes** - Improved error handling and logging during document sealing operations through the new job architecture. - **Refactor** - Transitioned from direct function calls for sealing documents to a job-triggering mechanism, promoting asynchronous processing and better scalability. - **Tests** - Enhanced test cases for improved structure and assertions, ensuring better reliability in document signing verification and date validation. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-26 19:33:39 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/documenso#1531
No description provided.