Skip to content

fix(plugins): guard plugin-http readBody against stream errors and closed responses - #1606

Open
swiezaczek wants to merge 1 commit into
NuvioMedia:mainfrom
swiezaczek:fix/plugins-http-readbody-and-response-closed
Open

swiezaczek wants to merge 1 commit into
NuvioMedia:mainfrom
swiezaczek:fix/plugins-http-readbody-and-response-closed

Conversation

@swiezaczek

Copy link
Copy Markdown
Contributor

Summary

Guard readBody() in services/plugin-http.cjs against stream error events and double settlement, and centralize response-closed checks in isResponseClosed() (writableEnded || finished || destroyed) for Node 4.4.3 / Node 8 compatibility.

PR type

  • Translation/localization only
  • Critical bug fix
  • Approved feature/change

Affected area

  • Shared web app
  • Samsung Tizen
  • LG webOS
  • Browser development mode
  • Playback
  • Audio tracks
  • Subtitles
  • Focus / Remote navigation
  • UI / Layout
  • Resume / Watch progress
  • Continue Watching
  • Next Episode / Auto-play
  • Packaging / Build
  • Nuvio TV Installer compatibility
  • webOS Homebrew wrapper
  • Documentation
  • Other

Why

On Node 4.4.3 (Tizen) and Node 8 (webOS), response.writableEnded is undefined (added in Node 12.9.0), and readBody() lacked an error listener and settled guard.

Issue or approval

Fixes #1603

Reproduction steps

  1. Send a request to plugin-http.cjs where the incoming stream emits error before end, or check response.writableEnded on Node 4.4.3 / Node 8.

Old behavior

readBody() could hang or settle twice on stream errors, and writableEnded was undefined on legacy Node.

New behavior

  • isResponseClosed(response) checks response.writableEnded || response.finished || response.destroyed and socket destruction.
  • readBody() uses a settled guard and attaches request.on("error").

Platform impact

  • Samsung Tizen: Safe on Node 4.4.3 / Node 8.
  • LG webOS: Safe on Node 8.
  • Browser development mode: No impact.
  • Installer / packaging: No impact.
  • Wrapper repositories: No impact.

UI / behavior / playback impact

  • No UI change
  • No behavior change
  • No playback change
  • UI changed only to fix a documented glitch/bug
  • Behavior changed only to fix a documented bug/regression
  • Playback changed only to fix a documented bug/regression
  • UI change has explicit maintainer approval
  • Behavior change has explicit maintainer approval
  • Playback change has explicit maintainer approval

Installer, packaging, or wrapper impact

  • No installer, packaging, or wrapper impact
  • Tizen .wgt packaging changed
  • webOS .ipk packaging changed
  • App identifiers or metadata changed
  • local.properties / environment handling changed
  • sync:tizen changed
  • sync:webos changed
  • Nuvio TV Installer compatibility changed
  • webOS Homebrew metadata support changed

Policy check

  • I have read and understood CONTRIBUTING.md.
  • This PR fits the current PR policy or has explicit maintainer approval.
  • This PR is small, focused, and limited to one issue.
  • This PR does not bundle unrelated refactors, cleanups, formatting, or drive-by changes.
  • This PR does not add dependencies, architecture changes, platform rewrites, installer rewrites, or broad refactors without approval.
  • This PR does not change UI unless it fixes a linked glitch/bug or has explicit approval.
  • This PR does not change behavior unless it fixes a linked bug/regression or has explicit approval.
  • This PR does not change playback unless it fixes a linked bug/regression or has explicit approval.
  • This PR does not change installer, packaging, app identifiers, release flow, or wrapper behavior without clear need or approval.
  • I included a linked issue, reproduction steps, and testing notes if this is a critical bug fix.
  • I listed the testing performed below.

Scope boundaries

Strictly limited to services/plugin-http.cjs stream/response guards. package.json is left untouched to avoid conflicts with concurrent PRs.

Testing

Devices / platforms tested

  • Verified locally on Windows (Node v24.13.0) with Prettier, ESLint, and test-plugin-http-readbody-and-closed.mjs.

Commands tested

npx --no-install prettier --check services/plugin-http.cjs scripts/test-plugin-http-readbody-and-closed.mjs
npx --no-install eslint --quiet services/plugin-http.cjs scripts/test-plugin-http-readbody-and-closed.mjs
node --test scripts/test-plugin-http-readbody-and-closed.mjs

Manual test flow

  • Ran test-plugin-http-readbody-and-closed.mjs (1/1 passing).

Screenshots / Video

Not a UI change

Logs

Not applicable

Regression risk

Low. Preserves existing Node 12+ writableEnded checks while adding finished fallback for Node 4.4.3 / Node 8.

Breaking changes

None.

Linked issues

Fixes #1603

This branch has not been deployed

No deployments
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.

[Bug]: plugin-http.cjs readBody lacks error/settled guard and response-closed check omits finished

1 participant