Problem/Motivation

The `wse_task_monitor` submodule tracks workspace publish progress by creating a "running" task record in the expirable `keyvalue` store on the `WorkspacePrePublishEvent`, and marking it completed on the `WorkspacePostPublishEvent`. When a publish throws an exception, the post-publish event is never dispatched, so the task is never marked complete or failed. It lingers in running state for one hour (the `keyvalue` TTL).

Separately, the workspace publish form attaches a JS library that opens an SSE stream and renders one progress bar per non-finished task it finds in the `keyvalue` store, regardless of whether that task came from the current request or a previous failed attempt. So every failed publish leaves one orphaned progress bar that will appear to every user viewing the publish form for the next hour.

Steps to reproduce

Throw an exception on workspace publishing - this can be achieved by running a simple listener that fires after the publish event.

Proposed resolution

The cleanest/simplest fix is to add failure handling to `WorkspacePublishingTaskMonitor`. We can subscribe to a kernel exception and mark the active task as Failed when an exception escapes publish. That keeps the server side events completion semantics working (since the task transitions to Failed and the JS clears the bar) and lets users see that the publish failed instead of staring at a 0% bar.

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork wse-3593702

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jamiehollern created an issue. See original summary.

amateescu made their first commit to this issue’s fork.

amateescu’s picture

Status: Active » Needs review

Thanks for the detailed bug report :) Opened a MR with a three-part fix:

  • A kernel.exception subscriber marks the active task failed when publishing throws, and cleans up its progress file.
  • A staleness fallback fails a running task that stops reporting progress past a timeout, so failures that skip the exception handler (fatal errors, Drush/cron publishes) also get cleared.
  • The SSE stream now sends a task-complete event for any task that finishes outside the stream, so the bar actually goes away (this also fixed a latent gap on the success path). Failed tasks now show an error message too.

  • amateescu committed c68230ea on 3.0.x
    task: #3593702 Add error handling for failed publishing
    
    By: amateescu...
amateescu’s picture

Version: 3.0.0-alpha3 » 3.0.x-dev
Status: Needs review » Fixed

The test failures are unrelated, so I merged it.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.