{"record":{"id":"e0fc6d72d118833e","repo":"nats-io/nats-server","slug":"thw-task-not-found","errorCode":null,"errorMessage":"thw: task not found","messagePattern":"thw: task not found","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/thw/thw.go","lineNumber":25,"sourceCode":"//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\npackage thw\n\nimport (\n\t\"encoding/binary\"\n\t\"errors\"\n\t\"io\"\n\t\"math\"\n\t\"time\"\n)\n\n// Error for when we can not locate a task for removal or updates.\nvar ErrTaskNotFound = errors.New(\"thw: task not found\")\n\n// Error for when we try to decode a binary-encoded THW with an unknown version number.\nvar ErrInvalidVersion = errors.New(\"thw: encoded version not known\")\n\nconst (\n\ttickDuration = int64(time.Second) // Tick duration in nanoseconds.\n\twheelBits    = 12                 // 2^12 = 4096 slots.\n\twheelSize    = 1 << wheelBits     // Number of slots in the wheel.\n\twheelMask    = wheelSize - 1      // Mask for calculating position.\n\theaderLen    = 17                 // 1 byte magic + 2x uint64s\n)\n\n// slot represents a single slot in the wheel.\ntype slot struct {\n\tentries map[uint64]int64 // Map of sequence to expires.\n\tlowest  int64            // Lowest expiration time in this slot.\n}\n","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/thw/thw.go#L7-L43","documentation":"Timing-wheel Update/Remove: no task exists at the indicated wheel slot/sequence — it already fired and was removed, or the seq is wrong. The lookup guard returns ErrTaskNotFound instead of mutating an empty slot.","triggerScenarios":"Thrown at server/thw/thw.go:25 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Treat removal of an already-fired task as success (idempotent)","Verify the task seq and wheel position before removal","Guard against concurrent removal of the same task"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}