{"record":{"id":"ccf8379753e13701","repo":"denoland/deno","slug":"err-method-not-implemented-ccf837","errorCode":"ERR_METHOD_NOT_IMPLEMENTED","errorMessage":"The _write() method is not implemented","messagePattern":"The _write\\(\\) method is not implemented","errorType":"exception","errorClass":"NodeError","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/internal/streams/writable.js","lineNumber":912,"sourceCode":"    } while (i < buffered.length && (state[kState] & kWriting) === 0);\n\n    if (i === buffered.length) {\n      resetBuffer(state);\n    } else if (i > 256) {\n      buffered.splice(0, i);\n      state.bufferedIndex = 0;\n    } else {\n      state.bufferedIndex = i;\n    }\n  }\n  state[kState] &= ~kBufferProcessing;\n}\n\nWritable.prototype._write = function (chunk, encoding, cb) {\n  if (this._writev) {\n    this._writev([{ chunk, encoding }], cb);\n  } else {\n    throw new ERR_METHOD_NOT_IMPLEMENTED(\"_write()\");\n  }\n};\n\nWritable.prototype._writev = null;\n\nWritable.prototype.end = function (chunk, encoding, cb) {\n  const state = this._writableState;\n\n  if (typeof chunk === \"function\") {\n    cb = chunk;\n    chunk = null;\n    encoding = null;\n  } else if (typeof encoding === \"function\") {\n    cb = encoding;\n    encoding = null;\n  }\n\n  let err;","sourceCodeStart":894,"sourceCodeEnd":930,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/node/polyfills/internal/streams/writable.js#L894-L930","documentation":"streams.Writable is abstract: the base prototype's _write() throws ERR_METHOD_NOT_IMPLEMENTED unless an _writev exists. The error surfaces on the first chunk the stream tries to flush (delivered to the write callback / 'error' event, destroying the stream), not at construction time.","triggerScenarios":"new Writable({highWaterMark: 16}) with no write option, followed by .write()/end(); class MyOut extends Writable {} that adds a constructor but never defines _write/_writev; a method misnamed write() or _write2 instead of _write.","commonSituations":"Porting stream samples; refactors that rename or drop _write; test fakes/mocks of Writable without a write implementation.","solutions":["Pass the implementation in options: new Writable({ write(chunk, enc, cb) { /* store */ cb(); } })","Implement _write(chunk, enc, cb) (or _writev) on the subclass prototype","Use a concrete stream (fs.createWriteStream, net.Socket) when you only need output"],"exampleFix":"// before\nclass Sink extends Writable {}\nnew Sink().end('x'); // ERR_METHOD_NOT_IMPLEMENTED on flush\n\n// after\nclass Sink extends Writable {\n  _write(chunk, _enc, cb) { process.stdout.write(chunk, cb); }\n}\nnew Sink().end('x'); // ok","handlingStrategy":"validation","validationCode":"function makeWritable(writeImpl) {\n  if (typeof writeImpl !== 'function') {\n    throw new Error('Writable requires a write(chunk, enc, cb) implementation');\n  }\n  return new Writable({ write: writeImpl });\n}","typeGuard":"const hasWriteImpl = (s) =>\n  typeof s._write === 'function' &&\n  (s._write !== Writable.prototype._write || typeof s._writev === 'function');","tryCatchPattern":"ws.on('error', (err) => {\n  if (err.code === 'ERR_METHOD_NOT_IMPLEMENTED') {\n    console.error('Implement _write(chunk, enc, cb) on this Writable subclass');\n  }\n});","preventionTips":["Always pass write() in constructor options or implement _write/_writev","Name the method exactly _write (leading underscore included)","Smoke-test custom streams with a single write() before wiring pipelines"],"tags":["streams","writable","node-compat","abstract-method"],"backgroundTag":"abstract-method-not-implemented","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}