{"record":{"id":"2398af5ee63433a5","repo":"hibiken/asynq","slug":"failed-to-write-task-result-w","errorCode":null,"errorMessage":"failed to write task result: %w","messagePattern":"failed to write task result: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"asynq.go","lineNumber":578,"sourceCode":"\t\tpassword = v\n\t}\n\treturn RedisFailoverClientOpt{MasterName: master, SentinelAddrs: addrs, SentinelPassword: password, DB: db}, nil\n}\n\n// ResultWriter is a client interface to write result data for a task.\n// It writes the data to the redis instance the server is connected to.\ntype ResultWriter struct {\n\tid     string // task ID this writer is responsible for\n\tqname  string // queue name the task belongs to\n\tbroker base.Broker\n\tctx    context.Context // context associated with the task\n}\n\n// Write writes the given data as a result of the task the ResultWriter is associated with.\nfunc (w *ResultWriter) Write(data []byte) (n int, err error) {\n\tselect {\n\tcase <-w.ctx.Done():\n\t\treturn 0, fmt.Errorf(\"failed to write task result: %w\", w.ctx.Err())\n\tdefault:\n\t}\n\treturn w.broker.WriteResult(w.qname, w.id, data)\n}\n\n// TaskID returns the ID of the task the ResultWriter is associated with.\nfunc (w *ResultWriter) TaskID() string {\n\treturn w.id\n}\n","sourceCodeStart":560,"sourceCodeEnd":588,"githubUrl":"https://github.com/hibiken/asynq/blob/d135f1439bee74e989b7f9b41ecd542cc87f024a/asynq.go#L560-L588","documentation":"Error returned by ResultWriter.Write when writing the task's result data to Redis fails. Because the writer stores results in the same Redis instance the server is connected to, this fires on connection problems, Redis errors, or a closed/unavailable broker; the underlying cause is wrapped via %w.","triggerScenarios":"Thrown at asynq.go:578 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped error (%w) to find the underlying redis/IO failure and fix it","Check that the task's result data is writable and the redis connection backing the server is healthy","Retry the task processing if the failure was transient (network blip, redis restart)"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d135f1439bee74e989b7f9b41ecd542cc87f024a","analyzedAt":"2026-09-07T19:02:34.660Z","contentChangedAt":"2026-09-07T19:02:34.660Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}