{"record":{"id":"b382885b6f8b656f","repo":"denoland/deno","slug":"err-missing-args-b38288","errorCode":"ERR_MISSING_ARGS","errorMessage":"The \"multicastAddress\" argument must be specified","messagePattern":"The \"multicastAddress\" argument must be specified","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/dgram.ts","lineNumber":293,"sourceCode":"   * import cluster from \"ext:deno_node/cluster\";\n   * import dgram from \"ext:deno_node/dgram\";\n   *\n   * if (cluster.isPrimary) {\n   *   cluster.fork(); // Works ok.\n   *   cluster.fork(); // Fails with EADDRINUSE.\n   * } else {\n   *   const s = dgram.createSocket('udp4');\n   *   s.bind(1234, () => {\n   *     s.addMembership('224.0.0.114');\n   *   });\n   * }\n   * ```\n   */\n  addMembership(multicastAddress: string, interfaceAddress?: string) {\n    healthCheck(this);\n\n    if (!multicastAddress) {\n      throw new ERR_MISSING_ARGS(\"multicastAddress\");\n    }\n\n    const { handle } = this[kStateSymbol];\n    const err = handle!.addMembership(multicastAddress, interfaceAddress);\n\n    if (err) {\n      throw errnoException(err, \"addMembership\");\n    }\n  }\n\n  /**\n   * Tells the kernel to join a source-specific multicast channel at the given\n   * `sourceAddress` and `groupAddress`, using the `multicastInterface` with\n   * the `IP_ADD_SOURCE_MEMBERSHIP` socket option. If the `multicastInterface`\n   * argument is not specified, the operating system will choose one interface\n   * and will add membership to it. To add membership to every available\n   * interface, call `socket.addSourceSpecificMembership()` multiple times,\n   * once per interface.","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/ext/node/polyfills/dgram.ts#L275-L311","documentation":"dgram Socket.addMembership(multicastAddress, interfaceAddress?) requires a truthy multicast group address; an empty string or missing value throws ERR_MISSING_ARGS before the kernel join (IP_ADD_MEMBERSHIP) is attempted. Note the check is falsiness-based, not format-based — a malformed non-empty string will fail later in addMembership with an errno exception instead.","triggerScenarios":"sock.addMembership('') or addMembership(undefined); the group address read from an env var that is unset in this deployment; calling addMembership before configuration finished loading.","commonSituations":"Multicast group from environment (e.g. MC_GROUP) missing in staging/production; shared helpers that assume a default group; config parsed after the socket already starts listening.","solutions":["Pass a valid IPv4 multicast group such as '224.0.0.114' (range 224.0.0.0-239.255.255.255)","Validate and default the configured address once at startup","Join inside the 'listening' event callback, where config is final and the socket is bound"],"exampleFix":"// before\nsock.addMembership(process.env.MC_GROUP);\n// after\nsock.addMembership(process.env.MC_GROUP ?? \"224.0.0.114\");","handlingStrategy":"validation","validationCode":"function isIpv4Multicast(addr) {\n  if (typeof addr !== \"string\" || addr === \"\") return false;\n  const o = addr.split(\".\").map(Number);\n  return o.length === 4 && o.every((n) => Number.isInteger(n) && n >= 0 && n <= 255) &&\n    o[0] >= 224 && o[0] <= 239;\n}\nconst group = process.env.MC_GROUP;\nif (!isIpv4Multicast(group)) throw new Error(`valid multicast address required, got ${group}`);\nsock.addMembership(group);","typeGuard":"const isMulticastAddress = (a) => typeof a === \"string\" && a !== \"\";","tryCatchPattern":"try { sock.addMembership(group); }\ncatch (e) {\n  if (e.code === \"ERR_MISSING_ARGS\") { /* group not configured; skip join */ }\n  else throw e;\n}","preventionTips":["Default and validate the multicast group at config load","Join groups inside the 'listening' callback","Validate the 224.0.0.0/4 range, not just non-emptiness"],"tags":["dgram","udp","multicast","arguments"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}