Skip to content

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

Merged
Kocal merged 1 commit into
symfony:2.xfrom
Fan2Shrek:optimise-turbo_stream_listen
Apr 19, 2025
Merged

[Turbo] Pass turbo_stream_listen topics to mercure if not defined#2694
Kocal merged 1 commit into
symfony:2.xfrom
Fan2Shrek:optimise-turbo_stream_listen

Conversation

@Fan2Shrek

@Fan2Shrek Fan2Shrek commented Apr 14, 2025

Copy link
Copy Markdown
Contributor
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
Comment thread src/Turbo/src/Bridge/Mercure/TurboStreamListenRenderer.php Outdated
@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

Kocal commented Apr 19, 2025

Copy link
Copy Markdown
Member

Thanks @Fan2Shrek.

@Kocal
Kocal merged commit 9d42463 into symfony:2.x Apr 19, 2025
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