Skip to content

fix: prevent flaky test on Python 3.10 in observable_test#13

Merged
knep merged 1 commit into
masterfrom
fix/observable-flaky-test
May 28, 2026
Merged

fix: prevent flaky test on Python 3.10 in observable_test#13
knep merged 1 commit into
masterfrom
fix/observable-flaky-test

Conversation

@knep
Copy link
Copy Markdown
Owner

@knep knep commented May 28, 2026

Problem

test_time_buffer_aggregated_read_until_closed was failing intermittently on Python 3.10 with:

AssertionError: Lists differ: ['lateX|lateY'] != []

Root cause

The test set up a time_buffered(100ms) observable. The helper _test_read_until_closed sends late messages from a thread that also sleeps 100ms, then closes the source. Both timers expire at approximately the same time (~t=100ms):

  1. Flush thread wakes at t=100ms, sees source_closed=True + buffer contains late messages → flushes data, closes the buffered observable
  2. Main thread's wait_buffer_flush (period×1.3+10ms = 140ms) hasn't returned yet → read_until_closed hasn't subscribed yet
  3. When read_until_closed eventually subscribes (t≈140ms), the observable is already closed — subscribe() immediately calls on_close() with no data → data = []

Fix

Change the buffer period from 100ms → 30ms. Flush cycles now land at t=30/60/90/120ms. The subscription is established at t≈49ms (30×1.3ms+10ms), well before the late messages arrive at t=100ms. The t=120ms flush picks them up while the subscriber is already in place.

Test plan

  • CI passes on all Python versions (3.10, 3.11, 3.12, 3.13)

🤖 Generated with Claude Code

…ython 3.10

The test used time_buffered(100ms) while _test_read_until_closed sends late
messages after a 100ms sleep. Both timers expire simultaneously, creating a
race: the flush thread can process the late messages and close the buffered
observable before read_until_closed subscribes (at t≈140ms), producing
data=[]. Switch to 30ms so flush cycles land at t=30/60/90/120ms; the
subscription is established at t≈49ms and the late-message flush happens at
t≈120ms, after the subscriber is in place.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@knep knep merged commit b3a0ea8 into master May 28, 2026
5 checks passed
knep pushed a commit that referenced this pull request May 29, 2026
Upgrades the web frontend from Vue 2 (Vue CLI + Webpack + Karma) to Vue 3 with
Vite and Vitest. Integrates cleanly with PRs #11#13 already on master (the new
DateField/TimeField unit tests were migrated to Vitest as part of this merge).

- Vue 3: v-model refactor, emits, lifecycle renames, Proxy reactivity (no more
  Vue.set/$set/$delete), :deep() selectors, Vue Router 4 + Vuex 4
- Vite build (assets in web/assets/; server web-build check updated)
- Vitest + jsdom: 821 passing, 54 browser-only skips
- Runtime bugs fixed: ace file-loader, v-if/v-for same element, reactive-Proxy
  identity (file dialog), array delete (param list), stale value-prop bindings
  (ScriptConfigForm, TimeField, DateField labels)
- Removed vue.config.js / babel.config.js / Karma entry; CI cleanup
- Verified in-browser: main + admin apps render with zero console errors

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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