Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/node/stream.ts>Writable#destroy

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
method Writable.prototype.destroy
import { Writable } from "https://deno.land/std@0.142.0/node/stream.ts";

Destroy the stream. Optionally emit an 'error' event, and emit a 'close'event (unless emitClose is set to false). After this call, the writable stream has ended and subsequent calls to write() or end() will result in an ERR_STREAM_DESTROYED error. This is a destructive and immediate way to destroy a stream. Previous calls towrite() may not have drained, and may trigger an ERR_STREAM_DESTROYED error. Use end() instead of destroy if data should flush before close, or wait for the 'drain' event before destroying the stream.

Once destroy() has been called any further calls will be a no-op and no further errors except from _destroy() may be emitted as 'error'.

Implementors should not override this method, but instead implement writable._destroy().

Parameters

optional
error: Error

Optional, an error to emit with 'error' event.