I updated the webform module from 5.3.0 to the latest version (6.1.0) and then when I click submit on one of my forms, I receive this ERROR:

Error: Call to undefined method Drupal\webform\Routing\WebformUncacheableResponse::addCacheableDependency() in Drupal\webform\Controller\WebformEntityController->javascript () (/home/acelys/www/uno-test.agglonet.com/web/modules /contrib/webform/src/Controller/WebformEntityController.php line 123)

I wrote the error on google and no response at all AND i looked at the line of code shown in the error message, I noticed that the addCacehableDependency() function was not used in the version Ancient and now it is used in the newer version of webform, but there is no error in this file where the code exists.

any ideas ? Thanks !

  • Have you done a drush deploy after upgrading the module looking for possible hook updates, etc? Have you cleared the cache?
    – jbarrio
    Nov 5, 2021 at 13:54
  • I’m voting to close this question because it’s a bug report for a contributed module and needs to be handled in the issue queue on Drupal.org
    – Clive
    Nov 11, 2021 at 15:35

1 Answer 1


You need to wait until this issue is fixed https://www.drupal.org/project/webform/issues/3247584

If you want to patch it yourself, addCacheableDependency() works only with the second response:

  public function javascript(Request $request, WebformInterface $webform) {
    $assets = $webform->getAssets();
    if ($webform->access('update')) {
      $response = new WebformUncacheableResponse($assets['javascript'], 200, ['Content-Type' => 'text/javascript']);
    else {
      $response = new CacheableResponse($assets['javascript'], 200, ['Content-Type' => 'text/javascript']);
    return $response;
  • iI works, Thank you !
    – OmarAc
    Nov 5, 2021 at 17:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.