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

fix(start): discard steam controller errors when closed #3161

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

phryneas
Copy link

@phryneas phryneas commented Jan 14, 2025

Stream Controller: try enqueue/close without throwing error

Both controller.enqueue and controller.close throw an error if the stream has already been closed.

This could be the case because the reading side just doesn't have interest in more incoming values and has closed the stream on the reading side.

Up until now, this would cause an error to be thrown on the console once more chunks or a close request were streamed in.

This wraps .close and .enqueue in a try..catch block and disregards the result.

Reading the standard I don't see any possible other reasons for an error to be thrown, so this should be fine.

Comment on lines +153 to +156
// controller = {
// enqueue: chunk => { try { c.enqueue(chunk); } catch {} },
// close: () => { try { c.close(); } catch {} },
// }
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing this here seems to be the place that is the most defensive - anywhere "further out", it could swallow errors e.g. if controller is still undefined etc.

phryneas added a commit to apollographql/apollo-client-nextjs that referenced this pull request Jan 14, 2025
Copy link

nx-cloud bot commented Jan 15, 2025

View your CI Pipeline Execution ↗ for commit 92b9a63.

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 3m 56s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1m 18s View ↗

☁️ Nx Cloud last updated this comment at 2025-01-15 05:42:35 UTC

Copy link

pkg-pr-new bot commented Jan 15, 2025

Open in Stackblitz

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@3161

@tanstack/create-router

npm i https://pkg.pr.new/@tanstack/create-router@3161

@tanstack/directive-functions-plugin

npm i https://pkg.pr.new/@tanstack/directive-functions-plugin@3161

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@3161

@tanstack/create-start

npm i https://pkg.pr.new/@tanstack/create-start@3161

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@3161

@tanstack/react-cross-context

npm i https://pkg.pr.new/@tanstack/react-cross-context@3161

@tanstack/react-router

npm i https://pkg.pr.new/@tanstack/react-router@3161

@tanstack/react-router-with-query

npm i https://pkg.pr.new/@tanstack/react-router-with-query@3161

@tanstack/router-cli

npm i https://pkg.pr.new/@tanstack/router-cli@3161

@tanstack/router-devtools

npm i https://pkg.pr.new/@tanstack/router-devtools@3161

@tanstack/router-generator

npm i https://pkg.pr.new/@tanstack/router-generator@3161

@tanstack/router-plugin

npm i https://pkg.pr.new/@tanstack/router-plugin@3161

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/@tanstack/router-vite-plugin@3161

@tanstack/server-functions-plugin

npm i https://pkg.pr.new/@tanstack/server-functions-plugin@3161

@tanstack/start

npm i https://pkg.pr.new/@tanstack/start@3161

@tanstack/start-plugin

npm i https://pkg.pr.new/@tanstack/start-plugin@3161

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@3161

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@3161

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@3161

commit: 92b9a63

@SeanCassiere SeanCassiere changed the title Stream Controller: try enqueue/close without throwing error fix(start): discard steam controller errors when closed Jan 15, 2025
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.

2 participants