Repository navigation
fix(url): Fix WOKWI_CLI_SERVER being ignored - #18
Merged
Merged
Conversation
Contributor
|
Thanks! |
urish
added a commit
that referenced
this pull request
Oct 2, 2026
Follow-up to #18, which made WokwiClient fall back to the env var. The lookup still happened at import time via a module-level constant, so setting `WOKWI_CLI_SERVER` after `import wokwi_client` was ignored.
Contributor
|
Fixed released as v0.4.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
WokwiClient.__init__falls back to the hard-coded public URL whenserveris not given:Because the client always passes a URL, the default in
transport.py(TRANSPORT_DEFAULT_WS_URL = os.getenv("WOKWI_CLI_SERVER", DEFAULT_WS_URL)) is never used. As a result,WOKWI_CLI_SERVERis silently ignored by bothWokwiClientandWokwiClientSyncunlessserveris passed explicitly.In practice this affects anyone using
wokwi/wokwi-ci-server-action. The action setsWOKWI_CLI_SERVER=ws://localhost:9177, but clients created with just a token, such as the one inpytest-embedded-wokwi, still connect towss://wokwi.com/api/ws/beta. The self-hosted CI server is bypassed and all simulations go to the shared public endpoint. In espressif/arduino-esp32 we've been seeing more and more intermittentConnectionClosedError: no close frame received or sentandHTTP 503failures because of this.Fix
Fall back to
TRANSPORT_DEFAULT_WS_URLinstead ofDEFAULT_WS_URL, so the existing environment variable lookup intransport.pyis respected. An explicitserverargument still takes priority.Tests
Added
tests/test_server_url.py, which runs without a token or network access and covers:serverand noWOKWI_CLI_SERVER: uses the public serverserverwithWOKWI_CLI_SERVERset: uses the environment variableserverwithWOKWI_CLI_SERVERset: uses the explicitserverEach case runs in a subprocess, because
WOKWI_CLI_SERVERis read whenwokwi_client.transportis imported.