AUR0771
Error Message
AUR0771: The aurelia instance must be fully stopped before it can be disposed
Description
This error occurs when the aurelia.dispose() method is called on an Aurelia instance that is still considered 'started' or 'running'. Before an Aurelia instance's container and associated resources can be disposed of, the application must be explicitly stopped using the aurelia.stop() method. The stop() method handles the graceful deactivation and detachment of the root component.
Cause
The primary cause is calling aurelia.dispose() without first calling await aurelia.stop() (or handling the promise appropriately) on the same instance. Common scenarios include:
Missing
stop()call: Forgetting to stop the application before attempting to dispose of it.Incorrect Order: Calling
dispose()immediately afterstop()without waiting for the asynchronousstop()operation to complete.Calling
dispose()on an instance that was never started: While less common, attempting to dispose of an instance that hasn't successfully completed thestart()and subsequentstop()sequence might lead to unexpected states, potentially triggering this error if internal state flags are inconsistent.
Solution
Call
stop()Beforedispose(): Always ensure thataurelia.stop()is called and awaited (or its promise handled) before callingaurelia.dispose().Await
stop(): Sincestop()is asynchronous, useawait aurelia.stop()or chaindispose()in the.then()callback of the promise returned bystop().
Example
Debugging Tips
Review the shutdown sequence of your Aurelia application.
Ensure that
stop()is called beforedispose().Verify that you are waiting for the
stop()promise to resolve before proceeding todispose(). Useawaitor.then().Check if multiple parts of your code might be attempting to stop or dispose of the same Aurelia instance concurrently, leading to race conditions.
Last updated
Was this helpful?