Skip to content

test(fetchium): failing repros for dynamic getConfig() subscribe - #19

Closed
jimmy-phantom wants to merge 1 commit into
mainfrom
jimmy/getconfig-subscribe-rebuild-tests
Closed

jimmy-phantom wants to merge 1 commit into
mainfrom
jimmy/getconfig-subscribe-rebuild-tests

Conversation

@jimmy-phantom

@jimmy-phantom jimmy-phantom commented May 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Two failing tests in poll.test.ts that reproduce a bug in fetchium's subscribe lifecycle.

getConfig() re-evaluates on every fetch and produces a fresh subscribe value, but setupSubscription in QueryResult.ts only consults config.subscribe at activation, on params change, or when no subscriber exists. Once a subscriber is running, later subscribe values from getConfig() are ignored — even though this.config is updated correctly by resolveAndApplyOptions after every fetch.

The two new failing tests demonstrate:

  1. State-dependent interval doesn't take effect after first fetch — poll({ interval: this.response?.ok ? 100 : 5000 }) captures the falsy branch (5000ms) at activation when this.response is undefined, and continues ticking at 5000ms forever even after response.ok === true.
  2. subscribe: undefined doesn't stop polling after a 404 — switching to subscribe: undefined based on this.response?.status === 404 has no effect; the captured-once subscriber keeps ticking.

The existing "getConfig subscribe" tests pass because they return a constant poll() value from getConfig(), never exercising the cross-fetch change. The new tests are added in the same describe block so the contrast is visible.

Draft because there's no fix yet — opening to align on the fix shape (rebuild subscriber when config.subscribe reference changes? per-tick subscribe re-evaluation hook? something else?).

Test plan

  • npx vitest run --project=unit src/__tests__/poll.test.ts — both new tests fail; the 6 existing tests still pass
  • Decide on the fix approach
  • Make the new tests pass without regressing the existing ones

🤖 Generated with Claude Code

getConfig() re-evaluates on every fetch and produces a fresh subscribe
value, but setupSubscription in QueryResult only consults config.subscribe
at activation, params change, or when no subscriber exists. Once a
subscriber is running, later subscribe values from getConfig() are ignored.

Adds two failing tests:

- A state-dependent interval (poll interval depending on this.response.ok)
  is captured at activation with response undefined, and never rebuilds
  once response.ok becomes true.
- subscribe: undefined returned from getConfig() after a 404 does not
  stop the running subscriber.

The existing "getConfig subscribe" tests pass because they return a
constant poll() value, never exercising the cross-fetch change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jimmy-phantom jimmy-phantom changed the title test(fetchium): failing repros for dynamic getConfig() subscribe fix(fetchium): rebuild subscriber when getConfig() subscribe changes May 8, 2026
@jimmy-phantom
jimmy-phantom force-pushed the jimmy/getconfig-subscribe-rebuild-tests branch from fd18085 to 6910a4e Compare May 8, 2026 00:07
@jimmy-phantom jimmy-phantom changed the title fix(fetchium): rebuild subscriber when getConfig() subscribe changes test(fetchium): failing repros for dynamic getConfig() subscribe May 8, 2026
@jimmy-phantom
jimmy-phantom deleted the jimmy/getconfig-subscribe-rebuild-tests branch May 18, 2026 15:28
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.

1 participant