# System.perspective.print in view .onShutdown script generates error when view closed in designer

**URL:** <https://forum.inductiveautomation.com/t/system-perspective-print-in-view-onshutdown-script-generates-error-when-view-closed-in-designer/99433>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [December 4, 2024, 4:58pm UTC](https://forum.inductiveautomation.com/t/system-perspective-print-in-view-onshutdown-script-generates-error-when-view-closed-in-designer/99433 "2024-12-04T16:58:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![e\_l](https://avatars.discourse-cdn.com/v4/letter/e/9de0a6/32.png) [@e\_l](https://forum.inductiveautomation.com/u/e_l)\
**Post date:** [December 4, 2024, 4:58pm UTC](https://forum.inductiveautomation.com/t/system-perspective-print-in-view-onshutdown-script-generates-error-when-view-closed-in-designer/99433/1 "2024-12-04T16:58:12Z")

</div>

Having system.perspective.print() in the .onShutdown event script of a view works and generates no errors in the browser session, but generates an error dialog when the view is closed in the designer (at least in version 8.1.37 and .42).  
I tested in a "empty" project with a view that I opened as a popup with only a close button and only

```python
system.perspective.print("onShutdown")

```

in the ,onShutdown event script. In the browser the string appears in the console when the view is closed, and no error appears in the logger. But when the view is closed in the designer, an error dialog pops up. The content varies, but in the empty test project and view it is **(in part)**...

```python
com.inductiveautomation.ignition.common.script.JythonExecException
Traceback (most recent call last):
  File "<function:runAction>", line 2, in runAction
	at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.lambda$operateOnPage$0(AbstractScriptingFunctions.java:79)
	at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.operateOnSession(AbstractScriptingFunctions.java:120)
	at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.operateOnPage(AbstractScriptingFunctions.java:47)
	at com.inductiveautomation.perspective.gateway.script.PerspectiveScriptingFunctions.print(PerspectiveScriptingFunctions.java:704)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
java.lang.IllegalStateException: java.lang.IllegalStateException: Page is not running.

--- There is a bunch more but I think this is a bug that can be easily reproduced ---

Ignition v8.1.42 (b2024061810)
Java: Azul Systems, Inc. 17.0.11

```

---

<div class="post-metadata">

**Author:** ![hulla](https://avatars.discourse-cdn.com/v4/letter/h/49beb7/32.png) [@hulla](https://forum.inductiveautomation.com/u/hulla)\
**Post date:** [September 11, 2025, 3:58pm UTC](https://forum.inductiveautomation.com/t/system-perspective-print-in-view-onshutdown-script-generates-error-when-view-closed-in-designer/99433/2 "2025-09-11T15:58:52Z")

</div>

I have the same experience. Its annoying. I have a shutDown script to close popups:

```python
def runAction(self):      
  popupId = self.custom.popupId
  system.perspective.closePopup(popupId)

```

When I close the view in the designer I get:

```python
Error running action 'system.onShutdown' on Components/shopfloor/sfTank@D: Traceback (most recent call last): File "<function:runAction>", line 4, in runAction at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.lambda$operateOnPage$0(AbstractScriptingFunctions.java:79) at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.operateOnSession(AbstractScriptingFunctions.java:120) at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.operateOnPage(AbstractScriptingFunctions.java:47) at com.inductiveautomation.perspective.gateway.script.PerspectiveScriptingFunctions.popupAction(PerspectiveScriptingFunctions.java:756) at com.inductiveautomation.perspective.gateway.script.PerspectiveScriptingFunctions.closePopup(PerspectiveScriptingFunctions.java:256) at jdk.internal.reflect.GeneratedMethodAccessor164.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) java.lang.IllegalStateException: java.lang.IllegalStateException: Page is not running. 

```

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 11, 2025, 4:02pm UTC](https://forum.inductiveautomation.com/t/system-perspective-print-in-view-onshutdown-script-generates-error-when-view-closed-in-designer/99433/3 "2025-09-11T16:02:58Z")

</div>

I've never tried it but would a simple error handling catch it?

```python
def runAction(self):      
  popupId = self.custom.popupId
  try:
    system.perspective.closePopup(popupId)
  except:
    pass

```

---

<div class="post-metadata">

**Author:** ![hulla](https://avatars.discourse-cdn.com/v4/letter/h/49beb7/32.png) [@hulla](https://forum.inductiveautomation.com/u/hulla)\
**Post date:** [September 11, 2025, 4:16pm UTC](https://forum.inductiveautomation.com/t/system-perspective-print-in-view-onshutdown-script-generates-error-when-view-closed-in-designer/99433/4 "2025-09-11T16:16:04Z")

</div>

Thanks, that works!

Another strange thing, I save, it is OK. I press ctrl+s multiple times, I get (no change in the code):

```python
Unable to run action 'system.onShutdown' on Components/shopfloor/sfTank@D$0:2: code could not be compiled.

```

But otherwise it works.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 11, 2025, 4:16pm UTC](https://forum.inductiveautomation.com/t/system-perspective-print-in-view-onshutdown-script-generates-error-when-view-closed-in-designer/99433/5 "2025-09-11T16:16:51Z")

</div>

Sorry, I don't know what that's about.
