{"record":{"id":"9539de94a49d25ab","repo":"googleapis/mcp-toolbox","slug":"toolbox-crashed-with-the-following-error-w","errorCode":null,"errorMessage":"toolbox crashed with the following error: %w","messagePattern":"toolbox crashed with the following error: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"cmd/internal/serve/command.go","lineNumber":123,"sourceCode":"\t\topts.Logger.InfoContext(ctx, \"Server ready to serve!\")\n\t\tif opts.Cfg.UI {\n\t\t\topts.Logger.InfoContext(ctx, fmt.Sprintf(\"Toolbox UI is up and running at: %s://%s:%d/ui\", protocol, opts.Cfg.Address, opts.Cfg.Port))\n\t\t}\n\n\t\tgo func() {\n\t\t\tdefer close(srvErr)\n\t\t\terr = s.Serve(ctx)\n\t\t\tif err != nil {\n\t\t\t\tsrvErr <- err\n\t\t\t}\n\t\t}()\n\t}\n\n\t// wait for either the server to error out or the command's context to be canceled\n\tselect {\n\tcase err := <-srvErr:\n\t\tif err != nil {\n\t\t\terrMsg := fmt.Errorf(\"toolbox crashed with the following error: %w\", err)\n\t\t\topts.Logger.ErrorContext(ctx, errMsg.Error())\n\t\t\treturn errMsg\n\t\t}\n\tcase <-ctx.Done():\n\t\tshutdownContext, cancel := context.WithTimeout(context.Background(), 10*time.Second)\n\t\tdefer cancel()\n\t\topts.Logger.WarnContext(shutdownContext, \"Shutting down gracefully...\")\n\t\terr := s.Shutdown(shutdownContext)\n\t\tif err == context.DeadlineExceeded {\n\t\t\treturn fmt.Errorf(\"graceful shutdown timed out... forcing exit\")\n\t\t}\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":105,"sourceCodeEnd":139,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/cmd/internal/serve/command.go#L105-L139","documentation":"runServe waits on select for either a server error on srvErr or ctx cancellation. If the running server emits an error while serving (not at startup), it is wrapped with 'toolbox crashed' and the process exits with that error.","triggerScenarios":"The serving goroutine pushes a non-nil error into srvErr — e.g., an accepted-connection handler failure, a fatal error inside Serve on one of the protocol servers, or the listener dying mid-run.","commonSituations":"Out of memory / resource exhaustion killing the listener, a panic in request handling surfacing as a server error, or a TLS/handshake misconfiguration appearing after startup.","solutions":["Read the wrapped root error for the crash reason","Check process logs and system resources (memory, file descriptors) at crash time","Upgrade the toolbox binary; check GitHub issues for the underlying error","If caused by client load, add rate limiting or increase ulimits before restarting"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"select {\ncase err := <-srvErr:\n    if err != nil {\n        return fmt.Errorf(\"toolbox crashed with the following error: %w\", err)\n    }\ncase <-ctx.Done():\n    // graceful shutdown path\n}","preventionTips":["Monitor memory/fd limits under load to avoid resource-driven crashes","Use a process supervisor (systemd/K8s) to auto-restart on crash","Keep the toolbox binary updated and review known crash issues"],"tags":["server","runtime","crash","go"],"backgroundTag":"server-runtime-crash","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}