{"record":{"id":"6e7f8dba2d5b1d29","repo":"projectdiscovery/nuclei","slug":"dialers-not-initialized-for-s-6e7f8d","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/smb/smb.go","lineNumber":96,"sourceCode":"// const smb = require('nuclei/smb');\n// const client = new smb.SMBClient();\n// const info = client.ConnectSMBInfoMode('acme.com', 445);\n// log(to_json(info));\n// ```\nfunc (c *SMBClient) ConnectSMBInfoMode(ctx context.Context, host string, port int) (*smb.SMBLog, error) {\n\texecutionId := ctx.Value(\"executionId\").(string)\n\treturn memoizedconnectSMBInfoMode(ctx, executionId, host, port)\n}\n\n// @memo\nfunc connectSMBInfoMode(ctx context.Context, executionId string, host string, port int) (*smb.SMBLog, error) {\n\tif !protocolstate.IsHostAllowed(executionId, host) {\n\t\t// host is not valid according to network policy\n\t\treturn nil, protocolstate.ErrHostDenied.Msgf(host)\n\t}\n\tdialer := protocolstate.GetDialersWithId(executionId)\n\tif dialer == nil {\n\t\treturn nil, fmt.Errorf(\"dialers not initialized for %s\", executionId)\n\t}\n\taddress := net.JoinHostPort(host, fmt.Sprintf(\"%d\", port))\n\tdialSMBInfo := func(ctx context.Context) (net.Conn, error) {\n\t\treturn dialer.Fastdialer.Dial(ctx, \"tcp\", address)\n\t}\n\tconn, err := dialSMBInfo(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// try to get SMBv2/v3 info\n\tresult, err := getSMBInfo(conn, true, false)\n\t_ = conn.Close() // close regardless of error\n\tif err == nil {\n\t\tupdateSMBv1Support(ctx, result, dialSMBInfo)\n\t\treturn result, nil\n\t}\n\n\t// try to negotiate SMBv1","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/js/libs/smb/smb.go#L78-L114","documentation":"connectSMBInfoMode in the smb JS library needs a per-execution dialer (fastdialer + network controls) from protocolstate.GetDialersWithId(executionId). This error means the registry returned nil for that execution ID: the nuclei protocol state was never initialized for this run, or was torn down, so there is no dialer to open TCP connections with.","triggerScenarios":"new smb.SMBClient().ConnectSMBInfoMode(host, 445) executed in a JS runtime whose executionId has no dialers: running the library outside a nuclei engine, in a raw unit test without protocolstate.InitProtocolState, or after the engine cleaned up state.","commonSituations":"Embedding nuclei as a library and invoking code-protocol helpers without initializing protocolstate; tests on pkg/js/libs executed without the engine fixture; re-using a stale executionId captured before a restart.","solutions":["Run the script as a code-protocol template inside a normal nuclei scan, where dialers are created automatically","In library/SDK mode, call protocolstate.InitProtocolState with the run's options before executing templates","In unit tests, initialize protocolstate (or a test dialer) in TestMain before invoking the JS lib","Make sure the executionId passed to the function matches the one the engine registered"],"exampleFix":"// before (unit test)\nclient.ConnectSMBInfoMode(ctx, 'dc01', 445) // dialers not initialized for <id>\n\n// after\nfunc TestMain(m *testing.M) {\n    _ = protocolstate.InitProtocolState(ctx, options) // registers dialers\n    os.Exit(m.Run())\n}","handlingStrategy":"validation","validationCode":"// Ensure dialers exist for this execution before using the JS lib\nif protocolstate.GetDialersWithId(executionId) == nil {\n    return fmt.Errorf(\"protocol state not initialized; cannot scan\")\n}","typeGuard":"func dialersReady(executionId string) bool {\n    return protocolstate.GetDialersWithId(executionId) != nil\n}","tryCatchPattern":"info, err := client.ConnectSMBInfoMode(ctx, host, 445)\nif err != nil && strings.Contains(err.Error(), \"dialers not initialized\") {\n    // engine-state bug, not a target problem: fix initialization, do not retry the target\n    return err\n}","preventionTips":["Initialize protocolstate once per process/run before executing any templates","In library mode, always enter through nuclei SDK entry points that set up state","Add a TestMain dialer fixture for unit tests that touch pkg/js/libs"],"tags":["initialization","internal","network","engine-state"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}