Switching to plan mode for everything before the application step seems to avoid the problem.
The problem seems to come when it’s stuck in a debug death loop with full permissions.