MCPcopy
hub / github.com/nestjs/nest / writeMessage

Method writeMessage

packages/core/router/sse-stream.ts:147–161  ·  view source on GitHub ↗

* Calls `.write` but handles the drain if needed

(
    message: MessageEvent,
    cb: (error: Error | null | undefined) => void,
  )

Source from the content-addressed store, hash-verified

145 * Calls `.write` but handles the drain if needed
146 */
147 writeMessage(
148 message: MessageEvent,
149 cb: (error: Error | null | undefined) => void,
150 ) {
151 if (message.id === undefined || message.id === null) {
152 this.lastEventId!++;
153 message.id = this.lastEventId!.toString();
154 }
155
156 if (!this.write(message, 'utf-8')) {
157 this.once('drain', cb);
158 } else {
159 process.nextTick(cb);
160 }
161 }
162}

Callers 2

sseMethod · 0.95
sse-stream.spec.tsFile · 0.80

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected