Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

503 status code after completing SseEmitter in onTimeout #34426

Open
stevijo opened this issue Feb 14, 2025 · 0 comments
Open

503 status code after completing SseEmitter in onTimeout #34426

stevijo opened this issue Feb 14, 2025 · 0 comments
Labels
status: waiting-for-triage An issue we've not yet triaged or decided on

Comments

@stevijo
Copy link

stevijo commented Feb 14, 2025

Hi all,

I experience an issue with SseEmitter in spring-framework 6.2.x vs 6.1.x. I am trying to complete an SseEmitter in the onTimeout callback in order to have a 200 http status code. This works fine in spring-framework 6.1.x and spring-boot 3.3.x, but breaks with spring-framework 6.2.x and spring-boot 3.4.x.

The commit that break this behaviour is the following e67f892.
In the past even when completion was already set, the completion handlers were still executed, when explicitly calling the complete method, this is not the case anymore and in case of onTimeout the completion has been set to true already before calling the callback.

I have provided a sample project here https://github.com/stevijo/sse-emitter

The code looks something like the following, where I expect a 200 status code after the 1s timeout, because I explicitly complete the emitter in the onTimeout callback:

@Controller
class SseController {
	@GetMapping(path = "/", produces = TEXT_EVENT_STREAM_VALUE)
	public SseEmitter stream() {
		final var emitter = new SseEmitter(1000l);
		emitter.onTimeout(() -> {
			emitter.complete();
		});

		return emitter;
	}
}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged or decided on
Projects
None yet
Development

No branches or pull requests

2 participants