Skip to content

fix(astro): Try-catch controller.close() usage #16693

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

mydea
Copy link
Member

@mydea mydea commented Jun 23, 2025

Hopefully fixes #16491

I could not get a reproducing test there for this 🤔 I figure this is "safe" to do, but not quite sure how/when this would happen. I would assume this was "introduced" by #15995, maybe @Fryuni has a clue how/when that could happen and if this is a reasonable change 🤔

@mydea mydea self-assigned this Jun 23, 2025
@Fryuni
Copy link
Contributor

Fryuni commented Jun 23, 2025

The error description indicates that calling enqueue on a closed controller fails, not close. close should be a no-op on an already closed controller.

The controller may be closed by downstream code for multiple reasons, like a canceled request or a closed connection.
In theory once the request is closed we should stop the iterations and close the original stream. But we could just consume it to the end discarding everything.

I think (would have to look at the docs) there is a .closed property we could check before calling enqueue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: Invalid state: Controller is already closed from Sentry Astro middleware
3 participants