{"record":{"id":"59e615b357fb15d5","repo":"denoland/deno","slug":"err-invalid-arg-value-59e615","errorCode":"ERR_INVALID_ARG_VALUE","errorMessage":"The property 'options.objectMode' is not supported. Received ${inspected}","messagePattern":"The property 'options\\.objectMode' is not supported\\. Received (.+?)","errorType":"error_code","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/net.ts","lineNumber":1479,"sourceCode":" *\n * It can also be created by Node.js and passed to the user when a connection\n * is received. For example, it is passed to the listeners of a `\"connection\"` event emitted on a `Server`, so the user can use\n * it to interact with the client.\n */\nfunction Socket(options) {\n  if (!ObjectPrototypeIsPrototypeOf(Socket.prototype, this)) {\n    return new Socket(options);\n  }\n\n  if (typeof options === \"number\") {\n    // Legacy interface.\n    options = { fd: options };\n  } else {\n    options = { ...options };\n  }\n\n  if (options.objectMode) {\n    throw new ERR_INVALID_ARG_VALUE(\n      \"options.objectMode\",\n      options.objectMode,\n      \"is not supported\",\n    );\n  }\n  if (options.readableObjectMode) {\n    throw new ERR_INVALID_ARG_VALUE(\n      \"options.readableObjectMode\",\n      options.readableObjectMode,\n      \"is not supported\",\n    );\n  }\n  if (options.writableObjectMode) {\n    throw new ERR_INVALID_ARG_VALUE(\n      \"options.writableObjectMode\",\n      options.writableObjectMode,\n      \"is not supported\",\n    );","sourceCodeStart":1461,"sourceCodeEnd":1497,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/node/polyfills/net.ts#L1461-L1497","documentation":"Deno's node:net polyfill rejects the `objectMode` option in the `net.Socket` constructor. A socket is a byte stream and only moves Buffer and string chunks, so object mode has no meaning on it. The polyfill throws ERR_INVALID_ARG_VALUE at construction time instead of silently ignoring the option.","triggerScenarios":"Constructing `new net.Socket({ objectMode: true })`, or `new net.Socket({ objectMode: true, fd: 3 })`. Also any factory that forwards a shared stream-options object into the Socket constructor, because the check runs before anything else in the constructor.","commonSituations":"Porting a library that switches a pipeline into object mode and reuses the same options object for sockets. Generic createStream(options) helpers that spread every stream option into every stream constructor. Code that runs unchanged on Node (which accepts the option) and then fails under Deno.","solutions":["Remove `objectMode` from the object passed to `new net.Socket(...)`.","If you need objects over the wire, keep the socket in binary mode and serialize with JSON.stringify on write and JSON.parse on 'data'.","Move object mode into a wrapping `stream.Duplex({ objectMode: true })` and connect it to the socket with pipe().","Filter known-unsupported keys (`objectMode`, `readableObjectMode`, `writableObjectMode`) out of shared options before constructing the socket."],"exampleFix":"// before\nnew net.Socket({ objectMode: true, port: 5432 });\n\n// after — keep the socket in binary mode and serialize objects yourself\nconst socket = new net.Socket({ port: 5432 });\nsocket.write(JSON.stringify({ id: 1 }));\nsocket.on('data', (chunk) => handle(JSON.parse(chunk.toString())));","handlingStrategy":"validation","validationCode":"const OBJECT_MODE_KEYS = ['objectMode', 'readableObjectMode', 'writableObjectMode'];\nfunction assertNoObjectMode(opts) {\n  for (const key of OBJECT_MODE_KEYS) {\n    if (opts?.[key]) throw new Error(`net.Socket does not support ${key}`);\n  }\n}\n// before constructing:\nassertNoObjectMode(socketOpts);\nconst socket = new net.Socket(socketOpts);","typeGuard":"type ByteSocketOptions = Omit<net.SocketConstructorOpts, 'objectMode' | 'readableObjectMode' | 'writableObjectMode'>;\nfunction isByteSocketOptions(v: unknown): v is ByteSocketOptions {\n  if (typeof v !== 'object' || v === null) return false;\n  const o = v as Record<string, unknown>;\n  return !o.objectMode && !o.readableObjectMode && !o.writableObjectMode;\n}","tryCatchPattern":"try {\n  socket = new net.Socket(opts);\n} catch (err) {\n  if (err?.code === 'ERR_INVALID_ARG_VALUE' && /objectMode/.test(err.message)) {\n    const { objectMode, readableObjectMode, writableObjectMode, ...rest } = opts;\n    socket = new net.Socket(rest);\n  } else throw err;\n}","preventionTips":["Never spread a shared stream-options object into net.Socket; pass an explicit minimal object.","Keep serialization (JSON lines, msgpack) at the edges of the socket, not object mode on the socket.","In cross-runtime libraries, unit-test socket construction with the library's real options object under Deno."],"tags":["net","socket","stream","objectmode","node-compat","deno"],"backgroundTag":"object-mode-unsupported","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}