{"record":{"id":"3c3c1f089b96b057","repo":"denoland/deno","slug":"err-method-not-implemented","errorCode":"ERR_METHOD_NOT_IMPLEMENTED","errorMessage":"The _implicitHeader() method is not implemented","messagePattern":"The _implicitHeader\\(\\) method is not implemented","errorType":"exception","errorClass":"NodeError","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/_http_outgoing.ts","lineNumber":683,"sourceCode":"    },\n    writable: true,\n    enumerable: true,\n    configurable: true,\n  },\n  pipe: {\n    __proto__: null,\n    value: function pipe() {\n      // OutgoingMessage should be write-only. Piping from it is disabled.\n      this.emit(\"error\", new ERR_STREAM_CANNOT_PIPE());\n    },\n    writable: true,\n    enumerable: true,\n    configurable: true,\n  },\n  _implicitHeader: {\n    __proto__: null,\n    value: function _implicitHeader() {\n      throw new ERR_METHOD_NOT_IMPLEMENTED(\"_implicitHeader()\");\n    },\n    writable: true,\n    enumerable: true,\n    configurable: true,\n  },\n  _finish: {\n    __proto__: null,\n    value: function _finish() {\n      assert(this.socket);\n      this.emit(\"prefinish\");\n    },\n    writable: true,\n    enumerable: true,\n    configurable: true,\n  },\n  // This logic is probably a bit confusing. Let me explain a bit:\n  //\n  // In both HTTP servers and clients it is possible to queue up several","sourceCodeStart":665,"sourceCodeEnd":701,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/ext/node/polyfills/_http_outgoing.ts#L665-L701","documentation":"The base OutgoingMessage implements _implicitHeader() as a stub that throws ERR_METHOD_NOT_IMPLEMENTED. Real subclasses override it: ClientRequest renders the request head (see error 231) and ServerResponse stores status line + headers. The hook is invoked whenever body data must be written before headers were explicitly sent, so the error surfaces only on a raw or incompletely subclassed OutgoingMessage.","triggerScenarios":"Instantiating OutgoingMessage directly and calling write()/end() without prior _storeHeader; creating a custom subclass (mocks, test doubles, protocol adapters) that overrides _send but not _implicitHeader, then relying on implicit header generation.","commonSituations":"Test harnesses mocking OutgoingMessage for unit tests of server internals; exotic protocol bridges built on OutgoingMessage instead of ClientRequest/ServerResponse; partial copies of Node internals missing the override after an upgrade.","solutions":["Use ClientRequest or ServerResponse instead of raw OutgoingMessage for concrete messages","In a subclass, implement _implicitHeader() to call this._storeHeader(...) with your status/request line and headers","In tests, stub the method explicitly: msg._implicitHeader = () => msg._storeHeader('HTTP/1.1 200 OK\\r\\n', {})"],"exampleFix":"// before\nclass FakeOutgoing extends OutgoingMessage {}\nconst m = new FakeOutgoing();\nm.write('hi'); // throws\n\n// after\nclass FakeOutgoing extends OutgoingMessage {\n  _implicitHeader() {\n    this._storeHeader('HTTP/1.1 200 OK\\r\\n', { 'content-length': '2' });\n  }\n}\nm.write('hi');","handlingStrategy":"fallback","validationCode":"if (typeof msg._implicitHeader !== 'function' || /\\[native/.test(String(msg._implicitHeader)) || msg._implicitHeader === OutgoingMessage.prototype._implicitHeader) {\n  msg._implicitHeader = () => msg._storeHeader('HTTP/1.1 200 OK\\r\\n', {});\n}","typeGuard":"const implementsImplicitHeader = (msg) => msg._implicitHeader !== OutgoingMessage.prototype._implicitHeader;","tryCatchPattern":"try { msg.write(chunk); } catch (e) { if (e.code === 'ERR_METHOD_NOT_IMPLEMENTED' && /_implicitHeader/.test(e.message)) { msg._implicitHeader = () => msg._storeHeader(head, headers); msg.write(chunk); } else throw e; }","preventionTips":["Use ClientRequest/ServerResponse for real messages","When subclassing OutgoingMessage, implement _implicitHeader from day one","Re-check required underscore overrides after runtime upgrades"],"tags":["http","outgoing","subclassing","internal-api","node-compat"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}