Skip to content

Retry v6 push registration after identity rejection#959

Open
czien wants to merge 4 commits into
bropat:developfrom
czien:fix/mega-push-registration-retry
Open

Retry v6 push registration after identity rejection#959
czien wants to merge 4 commits into
bropat:developfrom
czien:fix/mega-push-registration-retry

Conversation

@czien

@czien czien commented Jul 14, 2026

Copy link
Copy Markdown

Summary

Retry v6 register_push_token once when the cached Mega identity is rejected with CODE_NEED_NEGOTIATE_KEY or CODE_SIGNATURE_ERROR, then persist the refreshed Mega session after successful push registration.

Why

When the cached v6/Mega identity is stale, register_push_token can fail even though the account still has a valid Mega auth session. MegaHTTPApi.signedPost already clears cached identities for these response codes, so retrying the push-token registration lets the second attempt perform a fresh key exchange and register successfully.

Persisting the session after a successful push registration keeps the refreshed identity available for later startups.

Validation

  • Focused Jest test:
    npm test -- --runTestsByPath src/http/__test__/megaApiPushSelector.test.tsx --runInBand
  • Direct TypeScript compile:
    ./node_modules/.bin/tsc -p tsconfig.build.json
  • Prettier check:
    ./node_modules/.bin/prettier --check src/http/megaTransition.ts src/http/__test__/megaApiPushSelector.test.tsx

Also validated against a real Home Assistant Eufy WS add-on setup where v6 push registration recovered and doorbell ring events began reaching the original ringing sensor after this patch.

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.

2 participants