Skip to content

[Turbo] Pass turbo_stream_listen topics to mercure if not defined #2694

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

Merged
merged 1 commit into from
Apr 19, 2025

Conversation

Fan2Shrek
Copy link
Contributor

@Fan2Shrek Fan2Shrek commented Apr 14, 2025

Q A
Bug fix? yes
New feature? no
Docs? no
Issues See below
License MIT

Currently, the documentation says:

"If you're using a private hub, you can add { withCredentials: true } as the third argument to turbo_stream_listen() to authenticate with the hub."

However, this doesn’t actually work because the cookie is not created.
See: MercureExtension.php#L75

To make it work, we need to explicitly specify the topics again. The working call looks like this:
turbo_stream_listen("topics", "default", { subscribe: 'topics', withCredentials: true }

So I updated the implementation, adding the subscribe key if it's not already defined.

My mistake, sorry 😅

@carsonbot carsonbot added Bug Bug Fix Turbo Status: Needs Review Needs to be reviewed labels Apr 14, 2025
@Fan2Shrek Fan2Shrek force-pushed the optimise-turbo_stream_listen branch 2 times, most recently from 8a9cd1c to c5fc9fb Compare April 14, 2025 19:51
@Fan2Shrek Fan2Shrek force-pushed the optimise-turbo_stream_listen branch from c5fc9fb to f556d2a Compare April 15, 2025 06:13
@carsonbot carsonbot added Status: Reviewed Has been reviewed by a maintainer and removed Status: Needs Review Needs to be reviewed labels Apr 16, 2025
@Kocal
Copy link
Member

Kocal commented Apr 19, 2025

Thanks @Fan2Shrek.

@Kocal Kocal merged commit 9d42463 into symfony:2.x Apr 19, 2025
80 of 83 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug Fix Status: Reviewed Has been reviewed by a maintainer Turbo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants