JavaScript middleware: "responsePlugins" Couldn't dispatch request, driver 'otto' isn't available

Hi,

I am using Tyk version 5.9.1 and playing around with the javascript plugin (javascript is enabled with environment variable: TYK_GW_ENABLEJSVM=true).

I have already sucessfully implemented a javascript plugin for handling the http request.
The plugin is definine in the OAS Definition like this:

"x-tyk-api-gateway": {
    "info": {
      "id": "my_id",
      "name": "test with no auth",
      "orgId": "1",
      "state": {
        "active": true
      }
    },
    "middleware": {
      "global": {
        "pluginConfig": {
          "driver": "otto"
        },
        "prePlugins": [
          {
            "enabled": true,
            "functionName": "requestHeadersPlugin",
            "path": "/opt/tyk-gateway/middleware/process-requests.js"
          }
        ],
....
}

However if I want to use another script to handle the response, this do not work if I add the object responsePlugins:

According to the documentation:

My updated configuration:

"x-tyk-api-gateway": {
    "info": {
      "id": "my_id",
      "name": "test with no auth",
      "orgId": "1",
      "state": {
        "active": true
      }
    },
    "middleware": {
      "global": {
        "pluginConfig": {
          "driver": "otto"
        },
        "prePlugins": [
          {
            "enabled": true,
            "functionName": "requestHeadersPlugin",
            "path": "/opt/tyk-gateway/middleware/process-requests.js"
          }
        ],
        "responsePlugins": [
          {
            "enabled": true,
            "functionName": "responseMiddleware",
            "path": "/opt/tyk-gateway/middleware/process-response.js",
            "requireSession": true
          }
        ],
....
}

In the Tyk log I found the following error:

time="Feb 12 07:54:22" level=debug msg="Response hook 'CoProcessMiddleware' is called" prefix=coprocess
time="Feb 12 07:54:22" level=debug msg="Couldn't dispatch request object" error="Couldn't dispatch request, driver 'otto' isn't available"
2026/02/12 07:54:22 http: panic serving 192.168.80.5:38968: runtime error: invalid memory address or nil pointer dereference
goroutine 2714 [running]:
net/http.(*conn).serve.func1()
  net/http/server.go:1947 +0xbe
panic({0xa567000?, 0x113f7d30?})
  runtime/panic.go:791 +0x132
github.com/sirupsen/logrus.(*Entry).Dup(...)
  github.com/sirupsen/[email protected]/entry.go:82
github.com/TykTechnologies/tyk/gateway.(*BaseMiddleware).Copy(...)

In the documentation I found many ways to configure the middleware plugins and I am not sure which one is the correct one?:

Creating an OAS APi with the Playground :

I have also tried by implementing the json produced with the playground (see screenshot above) and I got the same error:

time="Feb 12 07:54:22" level=debug msg="Response hook 'CoProcessMiddleware' is called" prefix=coprocess
time="Feb 12 07:54:22" level=debug msg="Couldn't dispatch request object" error="Couldn't dispatch request, driver 'otto' isn't available"
2026/02/12 07:54:22 http: panic serving 192.168.80.5:38968: runtime error: invalid memory address or nil pointer dereference

Installing middleware OSS

Thank you for your help.

Hi Pascal,

Thanks for the question and for providing the details.

JavaScript middleware in Tyk uses the Otto engine, which is only supported in the request phase (prePlugins and postPlugins). Response hooks are not supported by Otto, which is why you’re seeing the ‘driver not available’ error.
See this table for more information: Custom Plugins - Tyk Documentation

For response‑phase logic, Tyk supports Golang, gRPC, and Python middleware.

Hope this helps!

Best,
Andres

1 Like

Hi Andes,

Thank you for your answer and for sharing the link to the documentation. This help a lot.

Greetings,

Pascal

@Andres_Tubelleja_III do you know if what I want to reach with the plugin is possible with the jq-transformations?

I think it would be nice if I can write a javascript directly in the middleware of an OAS-definition that can be executed.

I want to set for example an header to the request and that value in the response header too (work with tyk sessions metadata)