I have a scenario where I generate a complex PDF using an external API (DocMaker). The JSON payload is massive, and the generation process takes some time.
The Problem: I must run this logic in a Backend Workflow because if I try to run it directly from the frontend (Action in Page), I frequently hit browser timeout errors before the file is ready. The Backend environment has higher timeout limits and handles this heavy processing much better.
The Goal: I need the user to click “Generate”, have the frontend wait for this long-running Backend process to finish, and then get the file URL back to trigger a download.
My Question: Since “Schedule API Workflow” is asynchronous (fire and forget), is there a plugin or a pattern to call a Backend Workflow “synchronously” from the page?
Basically, I need the frontend to “hang tight” while the backend does the heavy lifting, and only proceed when the file is actually returned.
I know about the “API Connector to self” workaround, but is there a cleaner way or a specific plugin for this “Long Polling / Synchronous Wait” scenario?
Hi @ativosinfoeduc, I encountered a similar issue when building DocuPotion, so thought my two cents might be useful.
I ran into a problem with the 30-second timeout that Bubble has on all plugin server-side actions (the DocuPotion plugin has a ‘Create PDF’ action that users run in the frontend).
The 30-second limit was rarely hit, but occasionally a user would want to generate a very complex PDF (long repeating groups, multiple nested repeating groups, very data-heavy etc.) and it would trigger the error.
The solution I came up with was to turn the ‘Create PDF’ action into an asynchronous action and ask the user to setup a backend workflow that ‘processes’ the PDF on the backend.
So the PDF generation now works as follows:
User sets up backend workflow to process PDF (i.e. attach it to a ‘thing’ in your database)
User triggers ‘Create PDF’ action on frontend and provides callback URL
PDF is generated by DocuPotion API
DocuPotion calls the backend workflow to let user’s app know the PDF has been generated
Most relevant for you:
The user adds the ‘Trigger a custom event when data changes’ event to the frontend workflow
The custom event downloads the PDF in the users browser
This means that when the backend workflow processes the PDF, it downloads automatically in the frontend.
This section of the DocuPotion docs may be useful for more detail on this.
Is this the DocMaker you are using? The API and also the bubble plugin(s) has a section for webhook, which you can direct to a backend API workflow endpoint.