fix(sdk): warn when embedded request is dropped for exceeding link limit (#584) - #587
Open
chiliec wants to merge 1 commit into
Open
fix(sdk): warn when embedded request is dropped for exceeding link limit (#584)#587chiliec wants to merge 1 commit into
chiliec wants to merge 1 commit into
Conversation
The BridgeProvider silently drops the embedded request and regenerates a connect-only universal link whenever the link exceeds the 1024-char cap, so the dApp only sees dispatched: false with no indication that the link size was the reason (ton-connect#584). Emit a warning when this happens to a request that carried an embedded payload. Also centralise the 1024-char cap, which was duplicated in the SDK (maxUrlLength), the UI (MAX_LINK_LENGTH) and the tests, into a single exported MAX_UNIVERSAL_LINK_LENGTH constant so the values cannot drift.
|
@chiliec is attempting to deploy a commit to the TOP Innovations Ltd Team on Vercel. A member of the Team first needs to authorize it. |
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.
What
Closes #584.
BridgeProviderdrops the embedded request and regenerates a connect-only universal link whenever the link exceeds the 1024-character cap (packages/sdk/src/provider/bridge/bridge-provider.ts). As #584 notes, ordinary payloads (a connect request withton_proof+ two jetton transfers measures 1066 chars) cross that threshold, so "connect and pay in one tap" quietly becomes two steps — and the dApp only seesdispatched: falsewith no indication that the link size was the reason.Fix
This PR addresses the two concrete, non-behavioural points raised in the issue. It intentionally does not change the 1024 threshold or the wire encoding — whether the budget should grow (or the encoding shrink) is a design decision left to the maintainers, as the issue asks.
Make the drop observable. When the embedded request is dropped for length,
BridgeProvidernow emits alogWarning(using the SDK's existing logger) explaining that the link exceeded the limit and the embedded request will not be dispatched. The warning only fires when a request actually carried an embedded payload; connect-only links are unaffected. No behaviour changes — the same connect-only link is still returned.Centralise the magic number. The issue notes that
1024was written out separately inbridge-provider.ts, inpackages/ui/src/app/utils/web-api.tsasMAX_LINK_LENGTH, and in the SDK test, "with nothing tying them together" (both source sites even carry a comment asking for this). This PR introduces a single exportedMAX_UNIVERSAL_LINK_LENGTHconstant in the SDK and reuses it from all three places, so the values cannot drift apart.MAX_LINK_LENGTHis kept as a re-export for backwards compatibility.Tests
universal-link.test.tsnow imports the shared constant instead of re-declaring1024, plus a new assertion that pinsMAX_UNIVERSAL_LINK_LENGTH === 1024.2048turns exactly the drift-sensitive tests red (the new assertion + theexceedsMaxUrlLengthboundary cases); restoring to1024returns all green — proving the test actually locks the value.Validation (real results, Node 22.19, pnpm 10.14)
vitest run(full SDK suite): 183 passed (8 files)turbo run build --filter=@tonconnect/sdk: success (tsc + api-extractor + webpack)turbo run build --filter=@tonconnect/ui: success (typechecks the cross-packageMAX_UNIVERSAL_LINK_LENGTHimport)prettier --checkandeslinton all changed files: cleanFirst-time contributor here — happy to adjust the wording of the warning, the bump levels in the changeset, or the constant's name/location if you'd prefer them elsewhere.