Introduce the `spawn_failed` hook.

Closes GH-1252.