{"record":{"id":"d0eab0872a2c9fc3","repo":"projectdiscovery/nuclei","slug":"dialers-not-initialized-for-s-d0eab0","errorCode":null,"errorMessage":"dialers not initialized for %s","messagePattern":"dialers not initialized for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/js/libs/mysql/mysql.go","lineNumber":136,"sourceCode":"// const mysql = require('nuclei/mysql');\n// const info = mysql.FingerprintMySQL('acme.com', 3306);\n// log(to_json(info));\n// ```\nfunc (c *MySQLClient) FingerprintMySQL(ctx context.Context, host string, port int) (MySQLInfo, error) {\n\texecutionId := ctx.Value(\"executionId\").(string)\n\treturn memoizedfingerprintMySQL(ctx, executionId, host, port)\n}\n\n// @memo\nfunc fingerprintMySQL(ctx context.Context, executionId string, host string, port int) (MySQLInfo, error) {\n\tinfo := MySQLInfo{}\n\tif !protocolstate.IsHostAllowed(executionId, host) {\n\t\t// host is not valid according to network policy\n\t\treturn info, protocolstate.ErrHostDenied.Msgf(host)\n\t}\n\tdialer := protocolstate.GetDialersWithId(executionId)\n\tif dialer == nil {\n\t\treturn MySQLInfo{}, fmt.Errorf(\"dialers not initialized for %s\", executionId)\n\t}\n\n\tconn, err := dialer.Fastdialer.Dial(ctx, \"tcp\", net.JoinHostPort(host, fmt.Sprintf(\"%d\", port)))\n\tif err != nil {\n\t\treturn info, err\n\t}\n\tdefer func() {\n\t\t_ = conn.Close()\n\t}()\n\n\thandshake, err := fingerprintConn(conn, mysqlFingerprintTimeout)\n\tif err != nil {\n\t\treturn info, err\n\t}\n\n\tinfo.Host = host\n\tinfo.Port = port\n\tinfo.Protocol = \"mysql\"","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/js/libs/mysql/mysql.go#L118-L154","documentation":"Thrown by the memoized MySQL fingerprint function when protocolstate.GetDialersWithId(executionId) returns nil — i.e. no dialer set (fastdialer + network policy) was ever registered for the executionId carried in the JS context. All socket work in the nuclei JS runtime goes through these per-execution dialers, created by protocolstate.Init(options) keyed on options.ExecutionId. Without them, no network call can be made and every mysql.* network API fails immediately.","triggerScenarios":"Executing nuclei JS libraries (mysql, net, oracle, pop3, ...) from a context that never ran protocolstate.Init for that executionId: a standalone goja runtime, a Go unit test that calls the exported Go functions directly, or an SDK integration that builds its own execution context instead of using the nuclei engine. Also an executionId in ctx that differs from the one used at Init time.","commonSituations":"Embedding nuclei libs in Go tests without the lib/nuclei engine; reusing a stale context after the engine rotated execution ids; calling library code from a goroutine where the value of ctx key 'executionId' was overwritten or missing (though then the type assertion panics first); custom runners that skip engine initialization.","solutions":["Run the scripts through the nuclei engine (CLI or lib/nuclei NewEngine), which calls protocolstate.Init with the matching ExecutionId before executing JS","If embedding manually, call protocolstate.Init(&types.Options{ExecutionId: id, ...}) before any script execution and put the same id into the context under key 'executionId'","Check for executionId mismatch: the ctx value and the Init options must use the identical string","In tests, either init protocolstate or mock at a higher level instead of hitting the real dialer path"],"exampleFix":"// before (Go, standalone goja)\nctx := context.WithValue(context.Background(), \"executionId\", \"test-exec\")\nmysql.IsMySQL(ctx, \"acme.com\", 3306) // dialers not initialized for test-exec\n\n// after\nimport \"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/protocolstate\"\n\nctx := context.WithValue(context.Background(), \"executionId\", \"test-exec\")\nif protocolstate.ShouldInit(\"test-exec\") {\n  err := protocolstate.Init(&types.Options{ExecutionId: \"test-exec\"})\n  if err != nil { log.Fatal(err) }\n}\nmysql.IsMySQL(ctx, \"acme.com\", 3306)","handlingStrategy":"validation","validationCode":"// Go embedder: ensure dialers exist for this execution before running scripts\nif protocolstate.ShouldInit(executionId) {\n    if err := protocolstate.Init(&types.Options{ExecutionId: executionId /* network policy opts */}); err != nil {\n        return fmt.Errorf(\"init dialers: %w\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":"try { mysql.IsMySQL(host, port); } catch (e) { if (String(e).includes('dialers not initialized')) { log('runtime not initialized — run via nuclei engine'); return; } throw e; }","preventionTips":["Always execute nuclei JS libs through the nuclei engine or lib/nuclei SDK","Embedders: protocolstate.Init before first script; same ExecutionId in ctx","Never reuse contexts or clients across executions/ids","For tests, init protocolstate once in TestMain instead of mocking dialers"],"tags":["configuration","runtime-initialization","sdk","network"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}