Skip to content

Two more pages act destructively on beforeunload, which the back/forward cache turns into a dead page #8601

Description

@yangzhang75

Task Summary

beforeunload fires when a browser navigates away from a document, but the browser does not always discard that document: Chrome may keep it in the back/forward cache, and going back restores the JavaScript state exactly as it was left, re-running nothing. Anything a page destroys from a beforeunload binding therefore stays destroyed on a page that looks live.

#8599 is one instance of this, fixed for the operator canvas and the Form View in #8600. Grepping for the same shape found two more, neither of them on the path #8599 reports, so they were left out of that PR:

  • HubWorkflowDetailComponent calls workflowActionService.clearWorkflow() from a @HostListener("window:beforeunload") binding, and has nothing else to do there. Restored from the cache, the page should show an empty workflow. Not reproduced, inferred from the identical code shape. The fix is the same one fix(workflow): stop the workspace destroying itself on beforeunload #8600 applies: drop the beforeunload binding and leave the clear in ngOnDestroy.
  • AgentPanelComponent calls deactivateCurrentAgent() from its beforeunload binding. Whether deactivating on unload is releasing something server-side that ought to be released is a judgement about that subsystem, so this one needs an opinion from someone who knows it before it is changed.

The app's other four beforeunload bindings only write panel geometry to localStorage and are unaffected.

Task Type

  • Refactor / Cleanup

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions