GW fails to start on including plugin conf - "fatal error: runtime: no plugin module data"

Hello, I’m a tyk newbie trying to build a response plugin in go. The source compiled without errors. I’m not able to use the plugin compiler docker image at the moment, I built using go directly.
When I configure it into one of my api’s, the gateway service fails to start. I’ve confirmed the plugin conf is the issue - gw starts successfully without it.
I’m using tyk open source. The plugin binary is in the plugins directory. I’ve tried using 1.23 and 1.20, same symptoms. GW is running directly on the host, not containerized.

I found a couple of past threads referencing the same error message -

I’m assuming there is a version mismatch somewhere. I’d appreciate any direct pointers re what to check / change so versions can be aligned. If I’ve missed any relevant information, please point out, I’ll include.

OS, Tyk version, Go version

$ uname -a
5.15.0-130-generic #140-Ubuntu SMP Wed Dec 18 17:59:53 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

$ sudo ./tyk --version
5.7.0

$ go version
go version go1.23.4 linux/amd64

build

go build -trimpath -buildmode=plugin -v -o ./webhook_plugin.so webhook_plugin.go

go.mod:

module webhook_plugin
go 1.20

plugin section in api conf

“custom_middleware”: {
“post”: [
{
“name”: “WebhookPlugin”,
“path”: “./plugins/webhook_plugin.so”,
“require_session”: false
}
],
“driver”: “goplugin”
}

plugin code:

package main

import (
“bytes”
“encoding/json”
“io/ioutil”
“net/http”
)

func WebhookPlugin(rw http.ResponseWriter, res *http.Response, req *http.Request) {
webhookURL := “http://localhost:port/webhook-logger/”
data := “dummy-for-now”
jsonData, _ := json.Marshal(data)
go func() {
http.Post(webhookURL, “application/json”, bytes.NewReader(jsonData))
}()
}

func main() {}

gw log, from the point the plugin load starts:

time=“Jan 06 07:25:09” level=info msg=“Checking security policy: Open” api_id=1 api_name=helloget org_id=1
fatal error: runtime: no plugin module data
goroutine 1 gp=0xc0000061c0 m=0 mp=0x74c2800 [running]:
runtime.throw({0x4beca3f?, 0x181c0fb?})
#011runtime/panic.go:1023 +0x5c fp=0xc00139d370 sp=0xc00139d340 pc=0x184a5bc
plugin.lastmoduleinit()
#011runtime/plugin.go:20 +0x8cc fp=0xc00139d458 sp=0xc00139d370 pc=0x188236c
plugin.open({0xc000f090e0, 0x1b})
#011plugin/plugin_dlopen.go:77 +0x3ed fp=0xc00139d6d8 sp=0xc00139d458 pc=0x23ebe2d
plugin.Open(…)
#011plugin/plugin.go:80
github.com/TykTechnologies/tyk/goplugin.GetSymbol({0xc000f090e0?, 0x1?}, {0xc000d5e8a0, 0xd})
#011github.com/TykTechnologies/tyk/goplugin/goplugin.go:14 +0x2d fp=0xc00139d748 sp=0xc00139d6d8 pc=0x23ecaad
github.com/TykTechnologies/tyk/goplugin.GetHandler({0xc000f090e0?, 0x75265e0?}, {0xc000d5e8a0?, 0x1b?})
#011github.com/TykTechnologies/tyk/goplugin/goplugin.go:29 +0x1d fp=0xc00139d778 sp=0xc00139d748 pc=0x23ecc1d
github.com/TykTechnologies/tyk/gateway.(*GoPluginMiddleware).loadPlugin(0xc000f021b0)
#011github.com/TykTechnologies/tyk/gateway/mw_go_plugin.go:162 +0x439 fp=0xc00139dc38 sp=0xc00139d778 pc=0x43073d9
github.com/TykTechnologies/tyk/gateway.(*GoPluginMiddleware).EnabledForSpec(0xc000f021b0?)
#011github.com/TykTechnologies/tyk/gateway/mw_go_plugin.go:112 +0x30 fp=0xc00139e068 sp=0xc00139dc38 pc=0x4306e50
github.com/TykTechnologies/tyk/gateway.(*Gateway).mwAppendEnabled(0xc001301308, 0xc0013a1790, {0x54e2b20, 0xc000f021b0})
#011github.com/TykTechnologies/tyk/gateway/middleware.go:216 +0x2f fp=0xc00139e0c0 sp=0xc00139e068 pc=0x42f42ef
github.com/TykTechnologies/tyk/gateway.(*Gateway).processSpec(0xc001301308, 0xc00135a008, 0xc00117b6b0, 0xc0013ac8c8, 0xc0007aa8c0)
#011github.com/TykTechnologies/tyk/gateway/api_loader.go:465 +0x3205 fp=0xc0013a2d70 sp=0xc00139e0c0 pc=0x42b3ce5
github.com/TykTechnologies/tyk/gateway.(*Gateway).loadHTTPService(0x46edd60?, 0xc00135a008, 0x7386e68?, 0x1?, 0xc000eac060)
#011github.com/TykTechnologies/tyk/gateway/api_loader.go:791 +0x41f fp=0xc0013a59f8 sp=0xc0013a2d70 pc=0x42b73bf
github.com/TykTechnologies/tyk/gateway.(*Gateway).loadApps.func1(0xc00135a008, 0xc001301308, 0xc00117b680, 0x0, 0xc000dea7a0, 0xc00117b6b0, 0xc0013ac8c8, 0xc000eac060)
#011github.com/TykTechnologies/tyk/gateway/api_loader.go:1005 +0x4d2 fp=0xc0013a5ae8 sp=0xc0013a59f8 pc=0x42ba1d2
github.com/TykTechnologies/tyk/gateway.(*Gateway).loadApps(0xc001301308, {0xc00117b620, 0x5, 0x5})
#011github.com/TykTechnologies/tyk/gateway/api_loader.go:1012 +0x545 fp=0xc0013ad7e0 sp=0xc0013a5ae8 pc=0x42b9165
github.com/TykTechnologies/tyk/gateway.(*Gateway).loadGlobalApps(0xc001301308)
#011github.com/TykTechnologies/tyk/gateway/api_loader.go:688 +0xca fp=0xc0013ad828 sp=0xc0013ad7e0 pc=0x42b67aa
github.com/TykTechnologies/tyk/gateway.(*Gateway).DoReload(0xc001301308)
#011github.com/TykTechnologies/tyk/gateway/server.go:1003 +0x565 fp=0xc0013b1d00 sp=0xc0013ad828 pc=0x4382e45
github.com/TykTechnologies/tyk/gateway.(*Gateway).startServer(0xc001301308)
#011github.com/TykTechnologies/tyk/gateway/server.go:1965 +0xb2b fp=0xc0013b8ba0 sp=0xc0013b1d00 pc=0x438cc8b
github.com/TykTechnologies/tyk/gateway.Start()
#011github.com/TykTechnologies/tyk/gateway/server.go:1734 +0x1034 fp=0xc0013bff40 sp=0xc0013b8ba0 pc=0x43899f4
main.main()
#011github.com/TykTechnologies/tyk/main.go:9 +0xf fp=0xc0013bff50 sp=0xc0013bff40 pc=0x441b9af
runtime.main()
#011runtime/proc.go:271 +0x29d fp=0xc0013bffe0 sp=0xc0013bff50 pc=0x184dd7d
runtime.goexit({})
#011runtime/asm_amd64.s:1695 +0x1 fp=0xc0013bffe8 sp=0xc0013bffe0 pc=0x1887841
goroutine 2 gp=0xc000006c40 m=nil [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
#011runtime/proc.go:402 +0xce fp=0xc00007cfa8 sp=0xc00007cf88 pc=0x184e1ce
runtime.goparkunlock(…)
#011runtime/proc.go:408
runtime.forcegchelper()
#011runtime/proc.go:326 +0xb3 fp=0xc00007cfe0 sp=0xc00007cfa8 pc=0x184e033
runtime.goexit({})
#011runtime/asm_amd64.s:1695 +0x1 fp=0xc00007cfe8 sp=0xc00007cfe0 pc=0x1887841
created by runtime.init.6 in goroutine 1
#011runtime/proc.go:314 +0x1a
goroutine 3 gp=0xc000006e00 m=nil [runnable]:
runtime.goschedIfBusy()
#011runtime/proc.go:365 +0x28 fp=0xc00007d780 sp=0xc00007d768 pc=0x184e0e8
runtime.bgsweep(0xc00009c000)
#011runtime/mgcsweep.go:302 +0x14f fp=0xc00007d7c8 sp=0xc00007d780 pc=0x18359cf
runtime.gcenable.gowrap1()
#011runtime/mgc.go:203 +0x25 fp=0xc00007d7e0 sp=0xc00007d7c8 pc=0x182a065
runtime.goexit({})



#011runtime/asm_amd64.s:1695 +0x1 fp=0xc000090fe8 sp=0xc000090fe0 pc=0x1887841
created by github.com/TykTechnologies/tyk/gateway.(*HostUptimeChecker).Start in goroutine 26
#011github.com/TykTechnologies/tyk/gateway/host_checker.go:387 +0x150
tyk-gateway.service: Scheduled restart job, restart counter is at 5.
tyk-gateway.service: Start request repeated too quickly.
tyk-gateway.service: Failed with result ‘exit-code’.

Hi @svivek-tyk,

Welcome to Tyk!

Have you worked through the documentation here, which gives step-by-step instructions to build Go plugins without using Tyk’s Plugin Compiler?

Tyk 5.7.0 was developed using Go 1.22 (see the release notes here).