{"record":{"id":"26f807deaee012c2","repo":"pulumi/pulumi","slug":"allocating-resource-hook-callback-s-w","errorCode":null,"errorMessage":"allocating resource hook callback %s: %w","messagePattern":"allocating resource hook callback (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/pcl/runtime/interpreter.go","lineNumber":383,"sourceCode":"\t\t\t\"oldInputs\":  req.GetOldInputs(),\n\t\t\t\"newOutputs\": req.GetNewOutputs(),\n\t\t\t\"oldOutputs\": req.GetOldOutputs(),\n\t\t})\n\t\tif err != nil {\n\t\t\treturn &pulumirpc.ResourceHookResponse{Error: err.Error()}, nil\n\t\t}\n\n\t\trunErr, evalErr := runCommand(ctx, args)\n\t\tif evalErr != nil {\n\t\t\treturn &pulumirpc.ResourceHookResponse{Error: evalErr.Error()}, nil\n\t\t}\n\t\tif runErr != nil {\n\t\t\treturn &pulumirpc.ResourceHookResponse{Error: runErr.Error()}, nil\n\t\t}\n\t\treturn &pulumirpc.ResourceHookResponse{}, nil\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"allocating resource hook callback %s: %w\", hookName, err)\n\t}\n\n\t_, err = i.monitor.RegisterResourceHook(ctx, &pulumirpc.RegisterResourceHookRequest{\n\t\tName:         hookName,\n\t\tCallback:     cb,\n\t\tOnDryRun:     onDryRun,\n\t\tIgnoreErrors: ignoreErrors,\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"registering resource hook %s: %w\", hookName, err)\n\t}\n\n\t// Store the hook's registered name as a string so it can be referenced in hooks options.\n\ti.evalContext.SetVariable(h.Name(), cty.StringVal(hookName))\n\treturn nil\n}\n\nfunc (i *Interpreter) invoke(","sourceCodeStart":365,"sourceCodeEnd":401,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/pcl/runtime/interpreter.go#L365-L401","documentation":"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.","triggerScenarios":"srv.RegisterCallback returning an error while registering a resource hook — callback server closed, gRPC transport failure, or teardown racing registration.","commonSituations":"Concurrent cancellation of the deployment; language host losing its monitor connection; registering many hooks at once and hitting a resource limit.","solutions":["Retry the deployment; the cause is usually transient","Inspect the wrapped (%w) inner error for the underlying transport failure","If persistent, verify engine and language host versions are compatible"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err != nil {\n  var inner = errors.Unwrap(err);\n  if isConnErr(inner) { /* rerun deployment */ } else { /* inspect server state */ }\n}","preventionTips":["Do not cancel a deployment during program startup while hooks register","Monitor language-host to monitor connection stability","Report persistent failures with the wrapped inner error"],"tags":["pcl","hooks","grpc","registration"],"backgroundTag":"grpc-callback-registration-failure","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}