From 3dd9d71c328fea0f4b2ab4bc668e65ecd1eb1d8e Mon Sep 17 00:00:00 2001 From: Andrey Rakhmatullin Date: Fri, 24 Feb 2023 01:13:48 +0400 Subject: [PATCH] Correctly wrap connection errors into ResponseFailed. --- scrapy/core/http2/agent.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scrapy/core/http2/agent.py b/scrapy/core/http2/agent.py index 75731f525..215ea9716 100644 --- a/scrapy/core/http2/agent.py +++ b/scrapy/core/http2/agent.py @@ -6,7 +6,12 @@ from twisted.internet.base import ReactorBase from twisted.internet.defer import Deferred from twisted.internet.endpoints import HostnameEndpoint from twisted.python.failure import Failure -from twisted.web.client import URI, BrowserLikePolicyForHTTPS, _StandardEndpointFactory +from twisted.web.client import ( + URI, + BrowserLikePolicyForHTTPS, + ResponseFailed, + _StandardEndpointFactory, +) from twisted.web.error import SchemeNotSupported from scrapy.core.downloader.contextfactory import AcceptableProtocolsContextFactory @@ -83,8 +88,7 @@ class H2ConnectionPool: pending_requests = self._pending_requests.pop(key, None) while pending_requests: d = pending_requests.popleft() - # TODO: this is incorrect, errback takes a single exception - d.errback(errors) # type: ignore[arg-type] + d.errback(ResponseFailed(errors)) def close_connections(self) -> None: """Close all the HTTP/2 connections and remove them from pool