fix(gateway): clear pairing state on device token mismatch#22071
Merged
fix(gateway): clear pairing state on device token mismatch#22071
Conversation
src/gateway/client.ts
Outdated
| void clearDevicePairing(deviceId).catch((err) => { | ||
| logDebug(`failed clearing stale device pairing for device ${deviceId}: ${String(err)}`); | ||
| }); | ||
| logDebug(`cleared stale device-auth token and pairing for device ${deviceId}`); |
Contributor
There was a problem hiding this comment.
log message claims pairing is cleared, but clearDevicePairing is async and fire-and-forget (voided promise), so pairing might not be cleared when this logs
Suggested change
| logDebug(`cleared stale device-auth token and pairing for device ${deviceId}`); | |
| logDebug(`cleared stale device-auth token for device ${deviceId}`); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/gateway/client.ts
Line: 192
Comment:
log message claims pairing is cleared, but `clearDevicePairing` is async and fire-and-forget (voided promise), so pairing might not be cleared when this logs
```suggestion
logDebug(`cleared stale device-auth token for device ${deviceId}`);
```
How can I resolve this? If you propose a fix, please make it concise.05948a4 to
3546adc
Compare
3546adc to
ad38d1a
Compare
Closed
This was referenced Feb 23, 2026
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.
Summary
1008with adevice token mismatchreasonclearDevicePairingbehaviorWhy
This is the minimal safe salvage of #19562. It keeps only the pairing-recovery behavior needed for re-pairing after token mismatch and drops unrelated changes.
Changes
src/gateway/client.tssrc/infra/device-pairing.tssrc/gateway/client.test.tssrc/infra/device-pairing.test.tsValidation run locally
pnpm exec vitest run src/gateway/client.test.ts -t "GatewayClient close handling"pnpm exec vitest run src/infra/device-pairing.test.ts -t "clears paired device state by device id"Supersedes #19562 for this fix scope.
Greptile Summary
Added device pairing state cleanup alongside token cleanup when gateway receives close code 1008 with device token mismatch. The new
clearDevicePairingfunction removes paired device state by device ID.clearDevicePairingto remove paired device state by device IDclearDevicePairing(fire-and-forget) when clearing stale tokensConfidence Score: 4/5
Last reviewed commit: 4423f6e