Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Multichain - Cannot destructure property 'balance' of 'K[Z]' as it is undefined. and Cannot destructure property 'balance' of 'accounts[fromAddress]' as it is undefined. #25406

Closed
seaona opened this issue Jun 19, 2024 · 11 comments · Fixed by #25506
Assignees
Labels
regression-RC-12.0.0 release-12.1.0 Issue or pull request that will be included in release 12.1.0 release-blocker This bug is blocking the next release Sev1-high High severity; partial loss of service with severe impact upon users, with no workaround. team-confirmations Push issues to confirmations team type-bug

Comments

@seaona
Copy link
Contributor

seaona commented Jun 19, 2024

Describe the bug

Triggering a transaction on one chain, and without approving it, triggering a signature in another chain, whenever I reject/accept the first transaction, MM breaks with the error Cannot destructure property 'balance' of 'K[Z]' as it is undefined.

I've also seen it fail with this other message Cannot destructure property 'balance' of 'accounts[fromAddress]' as it is undefined.

Expected behavior

No response

Screenshots/Recordings

destructure-balance-z.mp4
cannot-destructure-balance-accts.mp4

Steps to reproduce

  1. Connect to the test dapp with Sepolia
  2. Connect to pancakeswap with Ethereum
  3. Trigger a swap in pancakeswap https://pancakeswap.finance/swap?chain=eth
  4. Without accepting/rejecting, go to the test dapp and trigger a signature
  5. Reject the first tx
  6. See how MM breaks

Error messages or log output

No response

Version

12.0.0

Build type

None

Browser

Chrome

Operating system

Linux

Hardware wallet

No response

Additional context

No response

Severity

No response

@github-project-automation github-project-automation bot moved this to To be fixed in Bugs by team Jun 19, 2024
@github-project-automation github-project-automation bot moved this to To be fixed in Bugs by severity Jun 19, 2024
@seaona seaona changed the title [Bug]: Multichain - Cannot destructure property 'balance' of 'K[Z]' as it is undefined. [Bug]: Multichain - Cannot destructure property 'balance' of 'K[Z]' as it is undefined. and Cannot destructure property 'balance' of 'accounts[fromAddress]' as it is undefined. Jun 19, 2024
@darkwing
Copy link
Contributor

Will continue trying to reproduce but I had no issue with this case but will keep trying:

Screen.Recording.2024-06-19.at.12.58.42.PM.mov

@darkwing
Copy link
Contributor

darkwing commented Jun 19, 2024

The actual error occurs in: ui/pages/confirmations/confirm-transaction-base/confirm-transaction-base.container.js are accepting or rejecting the first swap transaction. The error line is:

// FYI: This line was introduced 3 years ago...
const { balance } = accounts[fromAddress];

The problem is that fromAddress becomes undefined after (in this case) rejecting:

SCR-20240619-nljv

The from address comes from:

// FYI: This line was introduced 5 years ago
const {
    from: fromAddress,
    to: txParamsToAddress,
    gasPrice,
    gas: gasLimit,
    value: amount,
    data,
  } = (transaction && transaction.txParams) || txParams;

@darkwing darkwing added team-confirmations Push issues to confirmations team team-transactions Transactions team labels Jun 19, 2024
@dan437
Copy link
Contributor

dan437 commented Jun 20, 2024

@matthewwalsh0 can you or someone from the Confirmations team have a look?

@hesterbruikman hesterbruikman added team-wallet-api-platform Sev1-high High severity; partial loss of service with severe impact upon users, with no workaround. and removed team-transactions Transactions team labels Jun 20, 2024
@jiexi
Copy link
Contributor

jiexi commented Jun 20, 2024

Was able to reproduce Message: Cannot destructure property 'balance' of 'accounts[fromAddress]' as it is undefined.

@sleepytanya
Copy link
Contributor

sleepytanya commented Jun 20, 2024

Present in the latest build [https://github.com/MetaMask/metamask-extension/commit/eebc4d5b2284024eaeb190cddfa89990f593ca34]

Screen.Recording.2024-06-20.at.17.43.05.mov

@sleepytanya
Copy link
Contributor

I think this is the same bug? With different errors. We could combine them into one.

@digiwand digiwand self-assigned this Jun 21, 2024
@sleepytanya
Copy link
Contributor

  • Connect to test-dapp
  • Click button to start legacy send transaction; popup comes up, I see a "1" in the extension icon, I ignore the popup window
  • Open new tab, go to Uniswap
  • Click "Connect" button, click MetaMask; I see a "2" in the extension icon, no popup occurs
  • Click "Connect" button again, click MetaMask; I see a "3" in the extension icon, no popup occurs
  • After the first request is rejected and the subsequent request can be accessed MM can break with an error
Screenshot 2024-06-24 at 11 45 20

@sleepytanya
Copy link
Contributor

Start send+swap txs with low gas
Send another (approve) tx from a dapp
Confirmation is stuck on the spinner
Activity tab has two txs - Pending and Unapproved
Unapprovedtxs can't be rejected
If user rejects first tx MM displays an error Cannot destructure property 'balance' of 'Q[z]' as it is undefined.

Screenshot 2024-06-24 at 11 46 24

@sleepytanya
Copy link
Contributor

Screenshot 2024-06-24 at 11 47 34

@github-project-automation github-project-automation bot moved this from To be fixed to Fixed in Bugs by severity Jun 27, 2024
@github-project-automation github-project-automation bot moved this from To be fixed to Fixed in Bugs by team Jun 27, 2024
digiwand added a commit that referenced this issue Jun 27, 2024
…ned` fromAddress error when no transaction is loaded in ConfirmTransactionBase (#25506)

In `confirm-transaction-base.container.js`, while the transaction is
switching, the component may be in a state without transaction data. In
this case, we can handle the empty transaction data appropriately until
the expected data comes in to allow the user flow to continue without
breaking.

**note:** I was unable to reproduce this in `develop` after some time,
but I successfully repro'd this in `Version-v12.0.0` which allowed me to
verify the fix works. Possibly the underlying empty transaction data
state was fixed by other code in `develop`

This PR is planned to be cherry-picked for Version-v12.0.0

Fixes: #25406

See [Issue](#25406)
for repro steps

`confirm-transaction-base.container.js`
![CleanShot 2024-06-25 at 15 58
13@2x](https://github.com/MetaMask/metamask-extension/assets/20778143/4c3ccc3f-8583-4b76-b6cc-9bebc1f1045c)

See error in
[Issue](#25406)
screenshots

No error message is shown and app works as expected

<!-- [screenshots/recordings] -->

- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
@metamaskbot metamaskbot added the release-12.1.0 Issue or pull request that will be included in release 12.1.0 label Jun 27, 2024
danjm pushed a commit that referenced this issue Jun 27, 2024
…nce' of 'K[Z]' as it is undefined fromAddress` error when no transaction is loaded in ConfirmTransactionBase (#25566)

## **Description**

Cherry-pick #25506
for Version-v12.0.0

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/25566?quickstart=1)

## **Related issues**

Fixes: #25406


## **Manual testing steps**

1. Go to this page...
2.
3.

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
@benjisclowder
Copy link
Contributor

Collaborative Effort Required for Root Cause Analysis (RCA) on Critical Issues

We are quickly approaching the end of the quarter and we encourage you once again to take some moments and perform RCA on this critical issue. You may do so by answering the questions below:

1. What PR fixed the issue?
2. Can you pinpoint the commit from which the issue originated?
3. Write a short explanation of the technical cause of the bug
4. How could we have avoided merging this bug? What would have had to be different about our code, tests or processes?

4.1. Were there any missing unit, e2e or manual tests that could have preempted this issue?
4.2. Were there any other elements lacking, such as typed code, comprehensive documentation, well-architected APIs, etc., that might have prevented this issue?
4.3. If your answer to a and b is no, then is there anything at all that you can think of that, if it had been different before this bug was introduced, would have prevented it from being merged?

Please provide your answers as a reply to this comment and tag me as well.

You can read more about the initiative here. Thank you!

Tagging eng. who added the fix: @digiwand

@digiwand
Copy link
Contributor

Hi @benjisclowder,

  1. What PR fixed the issue?
    fix: Cannot destructure property 'balance' of 'K[Z]' as it is undefined fromAddress error when no transaction is loaded in ConfirmTransactionBase #25506

  2. Can you pinpoint the commit from which the issue originated?
    Unknown

  3. Write a short explanation of the technical cause of the bug

In confirm-transaction-base.container.js, while the transaction is switching, the component may be in a state without transaction data. It is a race-condition.

  1. How could we have avoided merging this bug? What would have had to be different about our code, tests or processes?
    4.1. Were there any missing unit, e2e or manual tests that could have preempted this issue?
    I think we are missing e2e tests.
    4.2. Were there any other elements lacking, such as typed code, comprehensive documentation, well-architected APIs, etc., that might have prevented this issue?
    I don't think we are supporting multiple dapps in our e2e tests.
    4.3. If your answer to a and b is no, then is there anything at all that you can think of that, if it had been different before this bug was introduced, would have prevented it from being merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression-RC-12.0.0 release-12.1.0 Issue or pull request that will be included in release 12.1.0 release-blocker This bug is blocking the next release Sev1-high High severity; partial loss of service with severe impact upon users, with no workaround. team-confirmations Push issues to confirmations team type-bug
Projects
Archived in project