Skip to content

fix: rebuild MPD upstream request after provider pooling#595

Merged
Bladestar2105 merged 2 commits into
mainfrom
codex/fix-upstream-fetch-using-stale-provider
May 7, 2026
Merged

fix: rebuild MPD upstream request after provider pooling#595
Bladestar2105 merged 2 commits into
mainfrom
codex/fix-upstream-fetch-using-stale-provider

Conversation

@Bladestar2105
Copy link
Copy Markdown
Owner

Motivation

  • The MPD proxy built upstreamUrl, backup URLs, and request headers from the original provider before provider-pooling could swap in a fallback account, allowing accounting to be charged to a different provider than the one actually contacted.
  • The change ensures provider selection and connection-accounting are always aligned with the actual upstream request to prevent provider overuse or bans.

Description

  • Moved MPD request construction (headers, upstreamUrl, and backupStreamUrls) in proxyMpd to run after findAvailableProvider and after the channel credentials are overridden, so the actual fetch uses the selected pooled provider account (src/controllers/streamController.js).
  • Added a focused regression test should build MPD upstream URL using pooled provider credentials and extended mocks to simulate a saturated provider and an available pooled provider (tests/security/provider_limit.test.js).
  • Minor test adjustments include importing fetch and adding a stream_id=202 channel fixture and pooled provider fixtures to the test DB mock.

Testing

  • Ran the targeted test: npm exec vitest run tests/security/provider_limit.test.js, and the test file passed (all tests in the file succeeded).
  • Ran linters with npm run lint; lint produced pre-existing warnings but no new errors were introduced.
  • The targeted test verifies that streamManager.add records the pooled provider id and that the upstream fetch is invoked with the pooled provider credentials and User-Agent as expected.

Codex Task

…tch-using-stale-provider

# Conflicts:
#	src/controllers/streamController.js
@Bladestar2105 Bladestar2105 merged commit 6be4e2c into main May 7, 2026
2 checks passed
@Bladestar2105 Bladestar2105 deleted the codex/fix-upstream-fetch-using-stale-provider branch May 7, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants