Handle mid-stream read failures in Rapid Diffs
What does this MR do and why?
If the network drops while Rapid Diffs is streaming the diff list (for example, Firefox's TypeError: Error in input stream), the error went unhandled and was reported to Sentry. The user saw a truncated list of changes with no explanation.
renderDiffsStream now catches TypeError rejections from renderHtmlStreams. It hides the loading indicator, sets the status to error, and shows the existing "Could not fetch all changes. Try reloading the page." alert. This is the same handling that HTTP 5xx responses already get. Other errors, including AbortError, are still rethrown: aborts are still ignored by withDebouncedAbortController, and real bugs still reach Sentry.
Tradeoffs and notes
- Network failures during a fetch are always
TypeErrors, but code bugs inside the stream pipeline can beTypeErrors too, and those would now show the alert instead of going to Sentry. There is no reliable way to tell the two apart. I chose this over adding a lot more code. - No stacktrace was resolved for the Sentry event. The code path comes from the
diffs_streambreadcrumb and from reading the code. I have not reproduced it in a browser. - The new specs call
renderDiffsStreamdirectly.withDebouncedAbortControlleris debounced at module level using real wall-clock time, so asserting on promises returned from the debounced actions depends on how long earlier tests took.
References
Screenshots or screen recordings
No new UI. This reuses the existing alert that HTTP 5xx responses already show.
How to set up and validate locally
- Open a merge request with many changed files in Rapid Diffs, in Firefox.
- In DevTools, throttle the network, then switch to Offline while
diffs_streamis still loading. - Check that the "Could not fetch all changes. Try reloading the page." alert appears and that no unhandled
TypeErrorshows in the console.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.