Skip to content

[Windows] [HTTP] Bun does not write an SSE message until the second message is written #15574

@wundersolutions-juanjo

Description

@wundersolutions-juanjo

What version of Bun is running?

1.1.38+bf2f153f5

What platform is your computer?

Microsoft Windows NT 10.0.19045.0 x64

What steps can reproduce the bug?

For the following code

import { createServer } from 'http';

const server = createServer();
server.on('request', (req, res) => {
	res.writeHead(200, {
		'Content-Type': 'text/event-stream',
		'Cache-Control': 'no-cache',
		'Connection': 'keep-alive',
	});
	res.write(`id: ${Date.now()}\ndata: Message 1\n\n`);

	// Bun does not write the first message until the second message is sent.
	// setTimeout(() => {
	// 	res.write(`id: ${Date.now()}\ndata: Message 2\n\n`);
	// }, 1000);
});
server.listen(8000);

After sending a request (Via curl localhost:8000, for example)

  • Bun never responds to the request, not sending data nor headers
  • Node correctly sends the response
  • If the settimeout block is uncommented, bun sends a response after one second, including both the first and second message

What is the expected behavior?

Bun's behaviour should match node's

What do you see instead?

Bun's behaviour does not match node's

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions