Uncaught GuzzleHttp\Exception\ConnectException in remote post hander

Created on 8 January 2024, over 1 year ago

Problem/Motivation

While using the remote post webform handler, we got a WSOD because of an uncaught ConnectionException:

GuzzleHttp\Exception\ConnectException: cURL error 28: Operation timed out after 30000 milliseconds with 0 bytes received (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://api-dev.stellahealth.net/connectflatform/forms/clientsurvey in GuzzleHttp\Handler\CurlFactory::createRejection() (line 210 of /var/www/html/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php).

Steps to reproduce

Get unlucky while using remote post.

Proposed resolution

This appears to be a result of a change made in Guzzle 7. This core issue looks closely related: #3188920: Make Guzzle exception handling forward-compatible with Guzzle 7 β†’

The remote post handle catches a RequestException (https://git.drupalcode.org/project/webform/-/blame/6.2.x/src/Plugin/Webf...)

    catch (RequestException $request_exception) {
      $response = $request_exception->getResponse();

      // Encode HTML entities to prevent broken markup from breaking the page.
      $message = $request_exception->getMessage();
      $message = nl2br(htmlentities($message));

      $this->handleError($state, $message, $request_url, $request_method, $request_type, $request_options, $response);
      return;
    }

In Guzzle 7 though, ConnectException is a sibling and not an extension on RequestException.

I'd love to just change RequestException to TransferException (the parent of both RequestException and ConnecException) but ConnectException does not have a getResponse method.

So we might need to add a new catch block.

Remaining tasks

User interface changes

N/A

API changes

N/A

Data model changes

N/A

πŸ› Bug report
Status

Active

Version

6.2

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States danflanagan8 St. Louis, US

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024