{"record":{"id":"8c704890395cf9d7","repo":"projectdiscovery/nuclei","slug":"dialers-with-executionid-executionid-not-found","errorCode":null,"errorMessage":"dialers with executionId {executionId} not found","messagePattern":"dialers with executionId (.+?) not found","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/js/global/scripts.go","lineNumber":133,"sourceCode":"\t\tName: \"isPortOpen\",\n\t\tSignatures: []string{\n\t\t\t\"isPortOpen(host string, port string, [timeout int]) bool\",\n\t\t},\n\t\tDescription: \"isPortOpen checks if given TCP port is open on host. timeout is optional and defaults to 5 seconds\",\n\t\tFuncDecl: func(ctx context.Context, host string, port string, timeout ...int) (bool, error) {\n\t\t\tif len(timeout) > 0 {\n\t\t\t\tvar cancel context.CancelFunc\n\t\t\t\tctx, cancel = context.WithTimeout(ctx, time.Duration(timeout[0])*time.Second)\n\t\t\t\tdefer cancel()\n\t\t\t}\n\t\t\tif host == \"\" || port == \"\" {\n\t\t\t\treturn false, errkit.New(\"isPortOpen: host or port is empty\")\n\t\t\t}\n\n\t\t\texecutionId := ctx.Value(\"executionId\").(string)\n\t\t\tdialer := protocolstate.GetDialersWithId(executionId)\n\t\t\tif dialer == nil {\n\t\t\t\tpanic(\"dialers with executionId \" + executionId + \" not found\")\n\t\t\t}\n\n\t\t\tconn, err := dialer.Fastdialer.Dial(ctx, \"tcp\", net.JoinHostPort(host, port))\n\t\t\tif err != nil {\n\t\t\t\treturn false, err\n\t\t\t}\n\t\t\t_ = conn.Close()\n\t\t\treturn true, nil\n\t\t},\n\t})\n\n\t_ = gojs.RegisterFuncWithSignature(runtime, gojs.FuncOpts{\n\t\tName: \"isUDPPortOpen\",\n\t\tSignatures: []string{\n\t\t\t\"isUDPPortOpen(host string, port string, [timeout int]) bool\",\n\t\t},\n\t\tDescription: \"isUDPPortOpen checks if the given UDP port is open on the host. Timeout is optional and defaults to 5 seconds.\",\n\t\tFuncDecl: func(ctx context.Context, host string, port string, timeout ...int) (bool, error) {","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/js/global/scripts.go#L115-L151","documentation":"The built-in isPortOpen TCP helper panicked because the execution context's dialers were missing. scripts.go fetches executionId from the JS context, looks up protocolstate.GetDialersWithId(executionId), and panics when nil — meaning protocolstate.Init never registered dialers for that execution id before the JS template ran.","triggerScenarios":"Running a JS template that calls IsPortOpen(host, port[, timeout]) in an embedded/SDK context where dialers were not initialized for the current ExecutionId; a race where the JS engine pool executes a request before Init completed or after dialers were torn down; executionId absent from ctx so the lookup key is wrong.","commonSituations":"lib/nuclei integrations driving the code protocol manually; custom runners that create the JS runtime but skip the dialer lifecycle; nuclei upgrades that moved from global dialers to per-execution-id dialers exposing a missing init step in third-party runners.","solutions":["Initialize dialers for the execution id before executing code-protocol templates: protocolstate.Init(opts) with opts.ExecutionId matching the one bound into the JS execution context.","Prefer the standard runner path, which performs Init before any engine work.","Guard with protocolstate.ShouldInit(executionId) at run start in SDK code paths.","Ensure the ctx passed to the JS execution actually carries the same executionId value used at Init."],"exampleFix":"// before\nresults, _ := engine.ExecuteWithResults(...) // JS calls IsPortOpen -> panic\n\n// after\nif protocolstate.ShouldInit(opts.ExecutionId) {\n    if err := protocolstate.Init(opts); err != nil { return err }\n}\nresults, _ := engine.ExecuteWithResults(ctxWithExecID, ...)","handlingStrategy":"validation","validationCode":"if protocolstate.ShouldInit(execID) {\n    if err := protocolstate.Init(opts); err != nil { return err }\n}\n// then execute the code template with ctx carrying execID","typeGuard":null,"tryCatchPattern":"// panic is a programming-error signal; fix init order rather than recovering.\n// In tests: require.NoError around engine setup so the panic surfaces at the guilty step.","preventionTips":["protocolstate.Init before any JS engine execution.","Same executionId in options, ctx, and engine.","Use the official runner when possible."],"tags":["panic","javascript","dialers","port-scan","sdk"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}