{"record":{"id":"054d1e0beb6c1579","repo":"dapr/dapr","slug":"init-timeout-for-component-s","errorCode":null,"errorMessage":"init timeout for component %s","messagePattern":"init timeout for component (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/runtime/processor/components.go","lineNumber":111,"sourceCode":"\t}\n\tcat := p.category(comp)\n\tif cat == \"\" {\n\t\treturn fmt.Errorf(\"incorrect type %s\", comp.Spec.Type)\n\t}\n\tmgr, ok := p.inlineManagers[cat]\n\tif !ok {\n\t\treturn fmt.Errorf(\"unknown component category: %q\", cat)\n\t}\n\ttimeout, err := time.ParseDuration(comp.Spec.InitTimeout)\n\tif err != nil || timeout <= 0 {\n\t\ttimeout = root.DefaultComponentInitTimeout\n\t}\n\tinitCtx, cancel := context.WithTimeout(ctx, timeout)\n\tdefer cancel()\n\n\tinitErr := p.runInlineInit(initCtx, comp, mgr)\n\tif errors.Is(initCtx.Err(), context.DeadlineExceeded) && initErr == nil {\n\t\tinitErr = fmt.Errorf(\"init timeout for component %s\", comp.LogName())\n\t}\n\tp.reportInline(ctx, comp, operatorv1.EventType_EVENT_INIT, initErr)\n\t// Match legacy proc.Init: return the sub-processor's wrapped error\n\t// directly. The \"outer\" rterrors.NewInit wrap is only applied on the\n\t// loop path (AddPendingComponent), not on the synchronous Init path.\n\treturn initErr\n}\n\nfunc (p *Processor) runInlineInit(ctx context.Context, comp compapi.Component, mgr inlineManager) error {\n\tif err := p.compStore.AddPendingComponentForCommit(comp); err != nil {\n\t\treturn err\n\t}\n\tif err := mgr.Init(p.security.WithSVIDContext(ctx), comp); err != nil {\n\t\tif derr := p.compStore.DropPendingComponent(); derr != nil {\n\t\t\treturn errors.Join(err, derr)\n\t\t}\n\t\treturn err\n\t}","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/dapr/dapr/blob/74ad41702745709bb15fe2114ff693b8c59bc3cc/pkg/runtime/processor/components.go#L93-L129","documentation":"The inline init path wraps component initialization in a context timeout parsed from spec.initTimeout (falling back to DefaultComponentInitTimeout, 5s). runInlineInit returned nil, but the init context reports DeadlineExceeded — meaning the manager gave up silently or returned just as the deadline hit — so the processor synthesizes this explicit timeout error rather than reporting success.","triggerScenarios":"A component whose Init blocks longer than its initTimeout (or the 5s default): statestores needing schema migration, bindings opening remote connections through slow networks, secret stores waiting on a slow KMS. Because the manager itself returned nil, only the expired context reveals the timeout.","commonSituations":"First-start cold connections to cloud resources (CosmosDB, AWS) exceeding 5s; initTimeout left at default in component YAML; CI or geographically distant environments with high latency; component init blocked on a DNS lookup that hangs.","solutions":["Raise spec.initTimeout in the component YAML to a duration that covers the slowest expected init (e.g. '30s' or '1m')","Fix the underlying slowness: network egress, DNS resolution, credentials round-trip, or pre-provision resources so init is fast","Reproduce init latency directly against the backend to pick a sane timeout rather than guessing","Watch ComponentInitFailed metrics/logs after the change to confirm the timeout no longer trips"],"exampleFix":"# before\nspec:\n  type: state.redis\n  version: v1\n  # no initTimeout -> 5s default\n# after\nspec:\n  type: state.redis\n  version: v1\n  initTimeout: '30s'","handlingStrategy":"validation","validationCode":"// Pre-flight: pick initTimeout from measured backend latency + margin\nconst measured = await timeFirstInit(component); // direct backend probe\nyaml.spec.initTimeout = `${Math.ceil((measured * 3) / 1000)}s`;","typeGuard":null,"tryCatchPattern":"// Server-side: catch init event errors and distinguish timeouts\nif (err.message.includes('init timeout for component')) { bumpInitTimeout(comp, '1m'); }","preventionTips":["Always set explicit initTimeout on components that touch remote services","Measure cold-start latency of backing services per environment","Watch ComponentInitFailed metrics for 'init' stage and alert"],"tags":["dapr","components","init","timeout","configuration"],"backgroundTag":null,"analyzedSha":"74ad41702745709bb15fe2114ff693b8c59bc3cc","analyzedAt":"2026-08-16T04:22:26.543Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}