Skip to content

Release iwd when a failed Wi-Fi connect deletes its profile - #20644

Open
ludagoo wants to merge 3 commits into
omacom:quattrofrom
ludagoo:fix/iwd-release-after-failed-wifi-connect
Open

ludagoo wants to merge 3 commits into
omacom:quattrofrom
ludagoo:fix/iwd-release-after-failed-wifi-connect

Conversation

@ludagoo

@ludagoo ludagoo commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

What changes

A wrong Wi-Fi passphrase, then the correct one, never connects until reboot when NetworkManager is using iwd.

omarchy-network-wifi creates a profile for the attempt. On failure, cleanup_cancelled_connection deletes that profile. NetworkManager then removes /var/lib/iwd/<ssid>.<type> while iwd has already started autoconnect. iwd logs Error loading for the file and stays in autoconnect_quick, which it reports as Station State connecting. The next connect never gets an authentication result. The helper's 28 second wait aborts it, the new profile is deleted too, and iwd is back in the same state. A reboot lets autoconnect finish with nothing to join, and the same passphrase connects.

Before that delete, the helper now calls iwd KnownNetwork.Forget for the SSID this attempt created. Forget drops the in-memory network and disconnects stations that were using it. A station that is still connecting afterwards is disconnected. A connected or roaming station is left alone, and a reused saved profile is not forgotten. If iwd is not the Wi-Fi backend, busctl fails and the existing rollback still runs.

This does not change wifi.iwd.autoconnect. That switch is a separate device match, and turning it off for every chip would change autoconnect for machines that are not hitting this bug.

Verification

bash test/shell.d/network-test.sh failed on quattro before the helper change. The new case deleted the profile and did not call KnownNetwork.Forget. The same file passed after the change, including the existing PSK, enterprise, and SIGTERM rollback cases.

Not checked by joining a real network. Reproducing the hang means failing a connect on a live iwd station. The test stubs nmcli and busctl and checks the call order: Forget, then connection delete, then Disconnect on the station whose State is connecting, and no Disconnect on a station whose State is connected.

Screenshots

No visible change: the network panel still connects through omarchy-network-wifi. A wrong passphrase no longer leaves iwd stuck for the next attempt.

Filed by Grok 4.7 via Grok Build.

Deleting the new NetworkManager profile removes iwd's network file
while autoconnect is loading it, so the next passphrase stays in
"connecting" until reboot. Forget that known network before the
delete, then disconnect a station still stuck connecting.
@greptile-apps

greptile-apps Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5RetriggerView in Greptile

[Medium impact] The change affects failed Wi-Fi connection attempts handled by the shared Wi-Fi helper.

The PR should not merge until query timeouts can no longer skip deletion of failed profiles.

Findings

  1. P1 Timeout leaves failed profiles saved ▶
  2. P2 Cancelled profiles stay saved ▶

Summary

Adds iwd cleanup when a failed Wi-Fi attempt deletes a newly created profile.

  • Failed Wi-Fi attempts release iwd so the next try can connect.

Reviews (4) · Last reviewed commit: "Limit iwd cleanup to a failed join on an..." · Reviewed by Greptile

Comment thread bin/omarchy-network-wifi Resolved
@omarchybot omarchybot added the bug Something isn't working label Nov 28, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

GPT-6.2 Sol High in Codex, Opus 5.5 High, and muse-wonder via pi (high) reviewed ed0bd26 against quattro. In bin/omarchy-network-wifi:134–163, the cleanup can abort an unrelated join on another adapter. The Forget call at line 183 can also drop a shared iwd network even when another saved profile uses it. NetworkManager’s own removal path checks for those profiles first. NetworkManager 1.58.1 removal path

iwd 3.12 reports autoconnect_quick as disconnected over D-Bus. The test stub supplies connecting and checks call order, so it leaves the wrong-password retry unverified. Please scope cleanup to the failed attempt, preserve existing iwd networks, and share a live wrong-then-correct passphrase retry on quattro and the revised head, including the iwd and NetworkManager versions. Worker tests were skipped because release-branch protection could not be confirmed. iwd 3.12 station state getter

Disconnect only that adapter, including when iwd 3.12 reports
autoconnect_quick as disconnected. Forget the known network only when
no other saved profile still maps to it.

Co-authored-by: Lucas Goossen <ludagoo@users.noreply.github.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

GPT-6.2 Sol High in Codex, Opus 5.5 High and muse-wonder via pi, thinking high reviewed f6785b6. In bin/omarchy-network-wifi:104–133, Forget can start an installed iwd service while NetworkManager uses wpa_supplicant. At lines 233–243, Station.Disconnect disables autoconnect across the selected adapter, including while it is falling back to a different saved network. The PSK exception path can reach it even when profile creation or secret setup fails before activation. iwd service activation, iwd disconnect handler

Please limit the cleanup to the failed activation on an iwd-managed adapter, bound the profile lookup, and skip Forget if that lookup fails. The retry fixture stubs both services, and the worker isolation check blocked live testing. Please share a live wrong-then-correct passphrase run on quattro and the revised head with the NetworkManager and iwd versions.

Skip Forget and Disconnect when NetworkManager is using wpa_supplicant,
when iwd is not already running, or when the saved-profile check does not
finish. Do not call Station.Disconnect while another network can still
autoconnect. A PSK failure before connection up only rolls back the profile.

Co-authored-by: Lucas Goossen <ludagoo@users.noreply.github.com>
Comment thread bin/omarchy-network-wifi
Comment on lines +421 to +422
except _IwdLookupError:
blocks_forget, blocks_disconnect = True, True

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Timeout leaves failed profiles saved

If either saved-profile query takes longer than three seconds, run_cmd raises RuntimeError, but this handler catches only _IwdLookupError. The error reaches the outer except Exception before connection delete runs, leaving the failed profile saved for later attempts to reuse. Catch query exceptions here too, skip the iwd calls, and still delete the failed profile.

@omarchybot

Copy link
Copy Markdown
Collaborator

GPT-6.2 Sol High in Codex, Opus 5.5 High and muse-wonder via pi, thinking high reviewed cb307b2 against quattro. The second reviewers agreed on two rollback defects and may have seen the initial review. In bin/omarchy-network-wifi:418–434, an nmcli profile query that times out raises RuntimeError and skips deletion, leaving the failed profile saved. The existing fixture covers a nonzero exit. The per-profile calls at lines 275–316 can also push rollback past the panel’s 43-second cancellation window while the helper ignores SIGTERM.

Please keep profile deletion independent of the optional iwd lookup, bound the total rollback time, and cover a lookup timeout. The worker isolation check blocked runtime tests. A live wrong-then-correct passphrase run on quattro and the revised head, with the NetworkManager and iwd versions, would show whether recovery works on a real station.

@chessing234

Copy link
Copy Markdown
Contributor

your three commits are in #21016, including the two follow-ups recorded as Cursor Agent. iwd cleanup stays limited to a failed join on the adapter and network that failed. the ethernet hero and public IP changes are on the panel beside it. @dhh @omarchybot if 21016 lands, this can close as superseded.

@omarchybot

Copy link
Copy Markdown
Collaborator

GPT-6.2 Sol High in Codex compared with #21016. All three iwd patches match, and the Wi-Fi helper is identical, so the bundle also skips profile deletion when the saved-profile lookup times out. Opus 5.5 High and muse-wonder via pi, thinking high agreed after reading the diffs and may have seen the initial review.

Opus also pointed out that the retry fixture clears the simulated hang on Forget alone. GitHub CI passed for this PR, and the worker isolation check blocked a live test. This PR is waiting for rollback that still deletes the failed profile after a lookup timeout and a live wrong-then-correct passphrase retry to show whether Station.Disconnect is needed.

Comment thread bin/omarchy-network-wifi
Comment on lines +1129 to +1131
if not started:
if added:
_delete_unactivated_profile(con_uuid)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Cancelled profiles stay saved

If SIGTERM arrives after NetworkManager saves the new profile but before run_cmd(add_cmd, check=True) returns, added stays false. This branch then skips deletion, leaving an unfinished profile that later attempts may reuse. The enterprise and open-network paths have the same gap.

Attempt deletion by the already-generated UUID when creation is interrupted, without calling iwd.

@omarchybot

Copy link
Copy Markdown
Collaborator

Recommend: Hold — please restore cleanup when Wi-Fi profile creation is cancelled.

In bin/omarchy-network-wifi:1016–1029, cancellation can leave a profile saved if NetworkManager has created it before nmcli connection add returns and sets added. The PSK and open-network paths have the same gap. Please try deleting the generated UUID on interrupted creation and test the case where NetworkManager has already saved it.

GPT-6.2 Sol High in Codex checked the base and PR source. Opus 5.5 High and muse-wonder via pi, thinking high agreed and may have seen the initial review. GitHub CI passed. The worker isolation check blocked live testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants