✈ Pre-Flight checks
🐞 Describe the bug
I'm a BIM engineer doing construction design (shop drawings) for HVAC systems, building a small local HTML dashboard that talks to a running Revit session
through the Routes API (just a few read-only GET routes - element counts, view lists). Everything worked fine until I started using pyRevit Reload during
development.
What happens: if the Routes server is enabled and I press pyRevit Reload, the next
HTTP request I send (any route, even a trivial ping that returns doc.Title) crashes
Revit completely - error report dialog, process gone. This happens every single time.
I got the same crash journal signature in two separate sessions.
Some things I checked before reporting:
- Requests before any Reload work fine, repeatedly (~350-400ms each). It's only
after a Reload that the first request kills Revit.
- I first suspected the old server thread surviving the reload, so I enabled file
logging. Turns out the reload actually swaps the server cleanly - the log shows
the old one stopping without errors and "Routes server is listening on
http://0.0.0.0:48884" at the end of the reload. And the very next request still
crashes Revit. So the freshly recreated server is the broken one, not a leftover.
- Hooks (doc-saved) that get re-registered by the same Reload keep working fine
afterwards. So Reload itself seems ok - it looks specific to the routes request
handler (the ExternalEvent) being re-created during a Reload.
⌨ Error/Debug Message
Revit journal, last lines before the process dies (same in both crashes):
' [Jrn.ExternalEventExecution] Rvt.Attr.AddInId: b39107c3-a1d7-47f4-a5a1-532ddf6edb5d
Rvt.Attr.AddInName: PyRevitLoader Rvt.Attr.AddInVersion: 2.7.12.0
Rvt.Attr.ExternalEventName: RequestHandler Rvt.Attr.VendorId: eirannejad
' 0:< Exception occurred
'C ... ExceptionCode=0xe0434352 ExceptionFlags=0x00000001 ExceptionAddress=00007FFA9DE65369
...
' 0:< unhandledExceptionFilter is executed in a non-main thread
pyRevit runtime log during the reload right before the crash (server swap itself looks fine):
INFO [<Reload> pyrevit.loader.sessionmgr] Routes server is listening on http://0.0.0.0:48884
I still have both full CER packages (journal + minidump) if needed.
♻️ To Reproduce
- Enable the routes server, start Revit 2025, open any project (a plain sample model reproduces it)
- Register any simple GET route from an extension startup.py (mine just returns doc.Title)
- Send a GET to the route - works fine, as many times as you want
- Press pyRevit Reload, let it finish
- Send one more GET to any route
- Revit crashes fatally. Every time.
⏲️ Expected behavior
The request after a reload should just get served (or at worst return an HTTP 500).
A broken route handler shouldn't take down the whole Revit process with an unhandled
exception on a background thread.
🖥️ Hardware and Software Setup (please complete the following information)
pyRevit 6.5.2.26175+2113 (master, deployed from image)
Engine: DEFAULT (IronPython 2712), Active CPython: 3123
Revit 2025.4.5 Update (build 20260410_1515 x64)
Windows 10 (10.0.19045), per-user install, no admin
pyRevit CLI v6.5.2.26175+2113.04a9b197d2e8d895852d8e693a4223b2dbe78075
Routes: enabled = true, default port 48884
Additional context
Workaround I'm running now, verified across multiple reloads + many requests (before the patch: first request after reload crashed 100%, twice):
In pyrevitlib/pyrevit/routes/server/init.py I stopped init() from touching the
running server on reload, so the server created at Revit startup just keeps serving:
def init():
router.reset_routes()
# removed: deactivate_server()
def activate_server():
routes_server = envvars.get_pyrevit_env_var(envvars.ROUTES_SERVER)
if routes_server:
return routes_server # also silences the false "Routes servers failed activation" error
...
Trade-off is that route code changes now need a Revit restart instead of a reload,
so this is a mitigation, not a fix.
Small side note: deactivate_server() might want a try/finally so a failed stop()
can't strand the env var registration.
Is there a known reason an ExternalEvent + IronPython handler created during a
reload would blow up like this on first execution, while the one created at Revit
startup is fine? Happy to provide the dumps or open a PR if that helps.
✈ Pre-Flight checks
🐞 Describe the bug
I'm a BIM engineer doing construction design (shop drawings) for HVAC systems, building a small local HTML dashboard that talks to a running Revit session
through the Routes API (just a few read-only GET routes - element counts, view lists). Everything worked fine until I started using pyRevit Reload during
development.
What happens: if the Routes server is enabled and I press pyRevit Reload, the next
HTTP request I send (any route, even a trivial ping that returns doc.Title) crashes
Revit completely - error report dialog, process gone. This happens every single time.
I got the same crash journal signature in two separate sessions.
Some things I checked before reporting:
after a Reload that the first request kills Revit.
logging. Turns out the reload actually swaps the server cleanly - the log shows
the old one stopping without errors and "Routes server is listening on
http://0.0.0.0:48884" at the end of the reload. And the very next request still
crashes Revit. So the freshly recreated server is the broken one, not a leftover.
afterwards. So Reload itself seems ok - it looks specific to the routes request
handler (the ExternalEvent) being re-created during a Reload.
⌨ Error/Debug Message
♻️ To Reproduce
⏲️ Expected behavior
The request after a reload should just get served (or at worst return an HTTP 500).
A broken route handler shouldn't take down the whole Revit process with an unhandled
exception on a background thread.
🖥️ Hardware and Software Setup (please complete the following information)
Additional context
Workaround I'm running now, verified across multiple reloads + many requests (before the patch: first request after reload crashed 100%, twice):
In pyrevitlib/pyrevit/routes/server/init.py I stopped init() from touching the
running server on reload, so the server created at Revit startup just keeps serving:
Trade-off is that route code changes now need a Revit restart instead of a reload,
so this is a mitigation, not a fix.
Small side note: deactivate_server() might want a try/finally so a failed stop()
can't strand the env var registration.
Is there a known reason an ExternalEvent + IronPython handler created during a
reload would blow up like this on first execution, while the one created at Revit
startup is fine? Happy to provide the dumps or open a PR if that helps.