Appearance
Problem Solving
Troubleshooting Common Issues
- "Task manager is shutting down: cannot queue task": This error occurs if you attempt to
QueueTask,QueueTaskWithPriority,QueueTaskOnce,QueueTaskWithPriorityOnce, orRunTaskaftermanager.Stop()ormanager.Kill()has been called, or if theCtxprovided duringNewTaskManagerinitialization has been cancelled. Ensure tasks are only submitted while the manager is actively running. - Resource Creation Failure: If your
OnCreatefunction returns an error,taskerwill log it, and the associated worker will not start (or aRunTaskcall will fail). Ensure your resource creation logic is robust and handles transient issues gracefully. - Workers Not Starting/Stopping as Expected:
- Verify your
WorkerCountandMaxWorkerCountsettings intasker.Config. - For dynamic scaling (bursting), ensure
BurstIntervalis configured and not set to 0. - Check that your main
context.Context(passed asCtxinConfig) and itscancelfunction are managed correctly, especially for graceful shutdown scenarios. - Review your
CheckHealthlogic; an incorrect implementation might lead to workers constantly restarting (thrashing) or not restarting when they should.
- Verify your
- Deadlocks/Goroutine Leaks: While
taskeris designed to prevent these within its core logic, improper usage (e.g., blocking indefinitely within yourOnCreate,OnDestroy, or task functions, or not using buffered channels for task results outside the library) can lead to such issues. Always ensure your custom functions (OnCreate,OnDestroy,taskFunc) do not block indefinitely. - Task Panics: It is generally recommended that your task functions (the
func(context.Context, R) (E, error)you pass toQueueTasketc.) internally recover from panics and convert them into errors. If a panic occurs and is not recovered within the task function itself, it will crash the specific worker goroutine that was executing it. Whiletaskerwill detect the worker's exit and attempt to replace it, unhandled panics can lead to unexpected behavior, lost task results, and potential resource leaks ifOnDestroyis not called due to an abrupt exit.