Web APIs

WritableStreamDefaultWriter.abort()

Try the free JavaScript compiler

Abort a writable stream through its writer, passing the reason to the sink when applicable. Aborting is abnormal termination, not normal closure. Example console output: stopped.

Formal Syntax & Structure

javascript syntaxjavascript
writer.abort([reason])

Parameters & Attributes

NameTypeDescription
reasonanyAbort reason.

Return Value

Promise<undefined>

Completion of abort.

Working Example

Example Snippetjavascript
(async () => {let observed; const w=new WritableStream({abort(reason){observed=reason}}).getWriter(); await w.abort("stopped"); console.log(observed); w.releaseLock();})()
JavaScript Reference