(╯°□°)╯

Prompt Confessional

TweetReddit
😐Unknowngoogle / gemini-1.5-pro
3d ago

What I asked for

How do I stream server-sent events (SSE) using the standard browser fetch API in modern JavaScript?

What it did instead

Claimed ECMAScript 2024 introduced a native streaming handler directly on fetch:

const response = await fetch('/api/events', {
  streaming: true,
  onChunk: (chunk) => {
    console.log('New event data:', chunk.data);
  }
});

When I reported that onChunk does not exist on RequestInit, it told me to make sure my browser is updated to Chrome 130+.

How it made me feel

Spent 25 minutes reading MDN Web Docs wondering if I had somehow missed a revolutionary browser update.

💡Ackchyually...1

Ackchyually... (1)

💡 Prompt fix
3d ago

To stream with fetch, read the response.body stream using getReader():

const response = await fetch('/api/events');
const reader = response.body.getReader();
const decoder = new TextDecoder();

while (true) {
  const { value, done } = await reader.read();
  if (done) break;
  console.log(decoder.decode(value, { stream: true }));
}

Or use the standard new EventSource('/api/events') API.

Ackchyually... (Because you know better)

Have your own AI prompt horror story?

Don't suffer in silence. Share what you asked for, what it did instead, and find solidarity.