Context:
In my Oracle APEX application, I've implemented a common pattern across all pages:
- Run Report Button: Initiates the generation of a report.
- Clear Button: Resets regions and redirects the user back to the same page.
- Cancel Button: Appears in a popup after clicking Run Report, intended to stop the report execution by triggering the Clear button functionality via jQuery.
The Issue:
While this setup works smoothly for most reports—allowing users to cancel the report execution and reset the page—I'm facing challenges with certain reports where the Cancel button doesn't work as expected. Specifically:
- Non-Responsive Cancel Button: On some pages, clicking Cancel doesn't stop the report immediately. Instead, the page remains unresponsive until the report finishes executing on the server.
- Affected Pages:
- Pages with Dynamic Actions (DAs) and additional processes.
- Even basic pages with only an Interactive Report (IR) region and a few buttons exhibit this issue.
Investigation and Findings:
Server-Side Processing Blocks Cancel Requests:
- Oracle APEX processes requests sequentially within the same user session.
- When a long-running report is executing, any subsequent requests (like clicking Cancel) are queued until the server finishes processing the current report.
- This behavior explains why the Cancel button doesn't interrupt the report execution immediately.
Browser and HTTP Limitations:
- Full page submissions (synchronous requests) can't be aborted once initiated.
- Browsers do not have a mechanism to cancel synchronous HTTP requests after they've been sent.
- Even if the user navigates away or attempts to redirect, the server continues processing the initial request.
Asynchronous vs. Synchronous Requests:
- Asynchronous (AJAX) Requests:
- Can be aborted by the browser or client-side scripts.
- Provide better control over long-running processes.
- Synchronous (Full Page) Requests:
- Cannot be easily canceled once started.
- The server must complete processing before handling new requests from the same session.