Skip to content

docs: fix WebSocketEndpoint example scope error - #43

Merged
lesnik512 merged 1 commit into
mainfrom
docs/fix-facts
Oct 3, 2026
Merged

lesnik512 merged 1 commit into
mainfrom
docs/fix-facts

Conversation

@lesnik512

Copy link
Copy Markdown
Member

Summary

Fix the WebSocketEndpoint example, which raised ScopeNotInitializedError.

Changes

  • The Echo.on_receive example injected Dependencies.user_service, a REQUEST-scoped provider. A WebSocket connection gets a SESSION-scoped child (starlette_websocket_provider, modern_di_starlette/main.py:18), so resolution failed with "Provider of scope REQUEST cannot be resolved in container of scope SESSION". It now injects the APP-scoped Dependencies.settings, and the scopes paragraph says WebSocket handlers can inject APP and SESSION dependencies but not REQUEST ones.
  • Removed an em dash in the setup_di note.
  • Footer: "with IoC container" -> "with an IoC container"; replaced the em dash in the org link line.

Verified with a scratch app (TestClient): the old example fails with the error above; the new one echoes over the WebSocket and the HTTPEndpoint route still returns 200.

Checklist

  • Lint and format pass (ruff)
  • Type check passes (ty)
  • Tests pass and new behavior is covered (docs only, no behavior change)
  • Build succeeds (uv build) if packaging or build config changed
  • Repo metadata stays consistent across the three surfaces (GitHub description, pyproject description, profile blurb) if this touches packaging

- Echo.on_receive injected a REQUEST-scoped provider from the SESSION child
- drop em dash
- footer wording
@lesnik512
lesnik512 merged commit 3470e05 into main Oct 3, 2026
14 checks passed
@lesnik512
lesnik512 deleted the docs/fix-facts branch October 3, 2026 09:53
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