Skip to content

fix(wdk, dapp-client): fix cron lastRun persistence and disambiguate redirect payloads#1018

Open
Ysh204 wants to merge 4 commits into
0xsequence:masterfrom
Ysh204:fix/cron-persistence
Open

fix(wdk, dapp-client): fix cron lastRun persistence and disambiguate redirect payloads#1018
Ysh204 wants to merge 4 commits into
0xsequence:masterfrom
Ysh204:fix/cron-persistence

Conversation

@Ysh204

@Ysh204 Ysh204 commented Jun 21, 2026

Copy link
Copy Markdown

Problem

This PR resolves two key issues:

  1. WDK Cron Job Last Run Persistence: On page reloads, cron job lastRun timestamps were overwritten to 0 in localStorage, leading to background jobs running too frequently.
  2. Redirect Payload UTF-8/Latin-1 Disambiguation: Redirect payload decoding used a try-catch pattern to auto-detect UTF-8. Legacy Latin-1 payloads with specific byte patterns (e.g., é) were incorrectly parsed as valid UTF-8 sequences (é), corrupting the data.

Solution

  1. WDK Cron: Updated the job checking loop to initialize in-memory lastRun times with the persisted value loaded from storage prior to running checks. This prevents overwriting the stored value with 0 when a job does not execute.
  2. Disambiguation: Added an explicit encoding=utf-8 search parameter to redirect request and response URLs. The client now decodes using UTF-8 only when the encoding=utf-8 parameter is present, otherwise safely falling back to Latin-1.

Verification

  • Added a full unit test suite for WDK cron job persistence in packages/wallet/wdk/test/cron.test.ts.
  • Updated existing tests and added a specific collision test case in packages/wallet/dapp-client/test/DappTransport.test.ts using legacy payload text é to ensure no regression occurs.
  • Both test suites compile, build, and pass successfully.

@Ysh204 Ysh204 requested a review from a team June 21, 2026 10:35
@Ysh204 Ysh204 requested a review from a team as a code owner June 21, 2026 10:35
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