{"record":{"id":"671583df1160cbb1","repo":"microsoft/aspire","slug":"timed-out-waiting-for-a-tracked-browser-protocol-response-to","errorCode":null,"errorMessage":"Timed out waiting for a tracked browser protocol response to '{method}'.","messagePattern":"Timed out waiting for a tracked browser protocol response to '(.+?)'\\.","errorType":"exception","errorClass":"TimeoutException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Browsers/BrowserLogsCdpConnection.cs","lineNumber":266,"sourceCode":"            _logger.LogTrace(\"Tracked browser protocol -> {Frame}\", BrowserLogsCdpProtocol.DescribeFrame(payload));\n\n            await _sendLock.WaitAsync(sendCts.Token).ConfigureAwait(false);\n            try\n            {\n                // Browser-level CDP transports are serialized so startup, reconnect, screenshot, and shutdown never\n                // interleave command frames on the same connection.\n                await _transport.SendAsync(payload, sendCts.Token).ConfigureAwait(false);\n            }\n            finally\n            {\n                _sendLock.Release();\n            }\n\n            return await pendingCommand.Task.ConfigureAwait(false);\n        }\n        catch (OperationCanceledException) when (!cancellationToken.IsCancellationRequested && !_disposeCts.IsCancellationRequested)\n        {\n            throw new TimeoutException($\"Timed out waiting for a tracked browser protocol response to '{method}'.\");\n        }\n        finally\n        {\n            _pendingCommands.TryRemove(commandId, out _);\n        }\n    }\n\n    private async Task ReceiveLoopAsync()\n    {\n        Exception? terminalException = null;\n\n        try\n        {\n            while (!_disposeCts.IsCancellationRequested)\n            {\n                var frame = await _transport.ReceiveAsync(_disposeCts.Token).ConfigureAwait(false);\n                _logger.LogTrace(\"Tracked browser protocol <- {Frame}\", BrowserLogsCdpProtocol.DescribeFrame(frame));\n","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Browsers/BrowserLogsCdpConnection.cs#L248-L284","documentation":"SendCommandAsync registers a pending CDP command and awaits its response with a timeout. If the browser never replies within the window (and cancellation was not user- or dispose-driven), the OperationCanceledException is converted to this TimeoutException naming the CDP method that went unanswered.","triggerScenarios":"Sending any CDP command (Target.createTarget, Target.getTargets, Target.attachToTarget, Target.closeTarget, discovery/instrumentation enable calls) whose response never arrives: browser hung, renderer blocked, or browser silently dropped the command.","commonSituations":"Browser process frozen or under heavy load; overloaded CI container; browser version that does not implement the sent method (no response ever returned); transient pipe stall just under the disconnect threshold.","solutions":["Retry the operation; if it repeats, tear down and reacquire the browser lease/connection.","Verify the browser process is alive and responsive.","Confirm the target browser version supports the CDP method being sent.","Increase the command timeout if the workload legitimately takes longer."],"exampleFix":"// before\nvar target = await connection.CreateTargetAsync(url); // throws on transient stall\n\n// after\ntry\n{\n    var target = await connection.CreateTargetAsync(url);\n}\ncatch (TimeoutException)\n{\n    lease = await registry.AcquireAsync(config, ct); // reconnect and retry\n}","handlingStrategy":"retry","validationCode":"// Check responsiveness cheaply before expensive CDP work\nusing var ping = await connection.SendCommandAsync(\"Browser.getVersion\"); // or a Process.HasExited check on the browser process","typeGuard":null,"tryCatchPattern":"for (var attempt = 0; attempt < 2; attempt++)\n{\n    try { return await connection.CreateTargetAsync(url); }\n    catch (TimeoutException) when (attempt == 0) { await ReacquireLeaseAsync(); }\n}","preventionTips":["Bound CDP work with reasonable timeouts and retry once before rebuilding the connection.","Monitor the browser process (HasExited) to detect hangs early.","Verify browser versions support the CDP methods you send."],"tags":["cdp","timeout","devtools-protocol","browser"],"backgroundTag":"request-timeout","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}