# "Error: rendering is already in progress" when trying to perform Turbo navigation from submit-end event handler

**URL:** <https://discuss.hotwired.dev/t/error-rendering-is-already-in-progress-when-trying-to-perform-turbo-navigation-from-submit-end-event-handler/3256>\
**Category:** General\
**Created:** [September 18, 2021, 11:29pm UTC](https://discuss.hotwired.dev/t/error-rendering-is-already-in-progress-when-trying-to-perform-turbo-navigation-from-submit-end-event-handler/3256 "2021-09-18T23:29:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![greenspud](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/greenspud/32/1767_2.png) [@greenspud](https://discuss.hotwired.dev/u/greenspud)\
**Post date:** [September 18, 2021, 11:29pm UTC](https://discuss.hotwired.dev/t/error-rendering-is-already-in-progress-when-trying-to-perform-turbo-navigation-from-submit-end-event-handler/3256/1 "2021-09-18T23:29:47Z")

</div>

Hello, I am trying to reset a modal form in the background when a 500 error occurs. The contents of this form lazy loads the `/new` object route. I seem to be able to successfully trigger the lazy load refresh by resetting the `src` attribute on the `<turbo-frame>`. (see [How to auto-reload frame? - #5 by ledermann](https://discuss.hotwired.dev/t/how-to-auto-reload-frame/1872/5)) However, when I do this from within the `submit-end` Stimulus event handler, it raises an error in my browser:

 ![image](https://canada1.discourse-cdn.com/flex027/uploads/stimulusjs/original/2X/b/baff4731034aa03386cb885bbe8344e9ec6ff6b5.png)

Here is my controller code. Weirdly, `Turbo` is undefined here even though it is available in other Stimulus controllers’ event handlers.

```auto
import { Controller } from "stimulus";
import { Turbo } from "@hotwired/turbo-rails";
import AlertsController from "./alerts_controller";

export default class extends Controller {
  static targets = ['closeButton', 'contentForm', 'dialog', 'refreshForm', 'validationErrorAlert'];

  connect() {
    // No validation error occurred so go ahead and close the modal since there's nothing more to display
    if(!this.hasValidationErrorAlertTarget) this.closeButtonTarget.click();
  }

  handleServerSideError() {
    let alerts_controller = new AlertsController;
    alerts_controller.createAlert('danger', 'A server side error has occurred');

    // Reload the lazy load of the modal form since the 500 error prevented a normal resetting of the form
    this.resetFrame();
  }

  resetFrame() {
    // Reset the value to the same thing. Turbo will detect the attribute access and reload.
    let frame = this.dialogTarget.closest('turbo-frame');
    frame?.setAttribute('src', frame.getAttribute('src'));
  }

  submitEnd(event) {
    console.log(`Turbo.status ${Turbo.navigator?.formSubmission?.state}`);
    console.log(`Turbo.session.started ${Turbo.session?.started}`);
    if (event.target != this.contentFormTarget) return;

    this.closeButtonTarget.click();
    if (!event.detail.success) this.handleServerSideError()

    console.log('form submission finished');
  }

}

```

Maybe I need to find some asynchronous way of triggering the `frame?.setAttribute('src', frame.getAttribute('src'));`?
