pulumi/pulumi · error

allocating resource hook callback %s: %w

Error message

allocating resource hook callback %s: %w

What it means

For resource hooks (pre/post, not error hooks), the interpreter allocates a callback via srv.RegisterCallback that the monitor invokes around resource operations. This error wraps a failure of that allocation. As with error hooks, it reflects a runtime/transport problem in setting up the callback, not a problem with the hook's command.

Source

Thrown at pkg/pcl/runtime/interpreter.go:383

			"oldInputs":  req.GetOldInputs(),
			"newOutputs": req.GetNewOutputs(),
			"oldOutputs": req.GetOldOutputs(),
		})
		if err != nil {
			return &pulumirpc.ResourceHookResponse{Error: err.Error()}, nil
		}

		runErr, evalErr := runCommand(ctx, args)
		if evalErr != nil {
			return &pulumirpc.ResourceHookResponse{Error: evalErr.Error()}, nil
		}
		if runErr != nil {
			return &pulumirpc.ResourceHookResponse{Error: runErr.Error()}, nil
		}
		return &pulumirpc.ResourceHookResponse{}, nil
	})
	if err != nil {
		return fmt.Errorf("allocating resource hook callback %s: %w", hookName, err)
	}

	_, err = i.monitor.RegisterResourceHook(ctx, &pulumirpc.RegisterResourceHookRequest{
		Name:         hookName,
		Callback:     cb,
		OnDryRun:     onDryRun,
		IgnoreErrors: ignoreErrors,
	})
	if err != nil {
		return fmt.Errorf("registering resource hook %s: %w", hookName, err)
	}

	// Store the hook's registered name as a string so it can be referenced in hooks options.
	i.evalContext.SetVariable(h.Name(), cty.StringVal(hookName))
	return nil
}

func (i *Interpreter) invoke(

View on GitHub (pinned to 793f7b2e16)

Solutions

  1. Retry the deployment; the cause is usually transient
  2. Inspect the wrapped (%w) inner error for the underlying transport failure
  3. If persistent, verify engine and language host versions are compatible
Defensive patterns

Strategy: retry

Try / catch

if err != nil {
  var inner = errors.Unwrap(err);
  if isConnErr(inner) { /* rerun deployment */ } else { /* inspect server state */ }
}

Prevention

When it happens

Trigger: srv.RegisterCallback returning an error while registering a resource hook — callback server closed, gRPC transport failure, or teardown racing registration.

Common situations: Concurrent cancellation of the deployment; language host losing its monitor connection; registering many hooks at once and hitting a resource limit.

Related errors


AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31). Data as JSON: /api/errors/26f807deaee012c2. Report an issue: GitHub.