After print job is cancelled script not run

What is the problem?

I don't know if I have done a configuration change, but the After print job is cancelled script is not run after I press the cancel button. Anyone have an idea where I should look for?

What did you already try to solve it?

  • Run in safe mode to disable all plugin
  • Add the line M300 S880 P300 at the begin of the script to generate a sound that will prove the script is run
  • Check and unchecked the serial connection behaviour: Log position on cancel and Attempt to abort any blocking heatups on cancel

Have you tried running in safe mode and if so did it solve the issue?

Yes!

Complete Logs

octoprint.log, serial.log or output on terminal tab at a minimum, browser error console if UI issue ... no logs, no support! Not log excerpts, complete logs.)

2020-11-13 11:36:39,101 - octoprint.util.comm - INFO - Changing monitoring state from "Starting" to "Printing"
2020-11-13 11:38:07,474 - octoprint.util.comm - INFO - Changing monitoring state from "Printing" to "Cancelling"
2020-11-13 11:38:08,759 - octoprint.printer.standard.job - INFO - Print job cancelled - origin: local, path: Fresco3_lens_0.3mm_PETG_MK3S_2m.gcode, owner: _api, user: _api
2020-11-13 11:38:08,764 - octoprint.plugins.DisplayLayerProgress - INFO - Printing stopped. Detailed progress stopped.
2020-11-13 11:38:08,830 - octoprint.settings - ERROR - Exception while trying to render script gcode:afterPrintCancelled
Traceback (most recent call last):
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint/settings.py", line 1620, in loadScript
    script = template.render(**context)
  File "/home/pi/oprint/lib/python3.7/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/home/pi/oprint/lib/python3.7/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/home/pi/oprint/lib/python3.7/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "/home/pi/.octoprint/scripts/gcode/afterPrintCancelled", line 14, in top-level template code
    {% if pause_position.x is not none %}
  File "/home/pi/oprint/lib/python3.7/site-packages/jinja2/environment.py", line 471, in getattr
    return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'pause_position' is undefined
2020-11-13 11:38:08,848 - octoprint.util.comm - INFO - Changing monitoring state from "Cancelling" to "Operational"
2020-11-13 11:38:08,900 - octoprint.plugins.DisplayLayerProgress - INFO - Printing stopped. Detailed progress stopped.

Additional information about your setup

OctoPrint version, OctoPi version, printer, firmware, browser, operating system, ... as much data as possible

OctoPrint 1.4.2, OctoPi 0.17 on raspberry pi 3b, MK3S + MMU2S (mmu not connected), firmware Prusa 3.9.1

It works in safe mode?
Then a plugin might be the problem.
Please upload the logs and the script you want to use

My mistake, the safe mode did not solve the issue. But I found the problem, it was an error with a variable in my script. I was under the impression that the script will be run until it find an error, but I was wrong. If there is an error at the end of the script, the whole script is not run.

1 Like