1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/app/scripts/controllers
Mark Stacey 9c06b07c3c
Synchronously update transaction status (#8563)
All transaction status updates were moved into a `setTimeout` callback
and wrapped in a `try...catch` block in #4131, apparently in an attempt
to prevent failures in event subscribers from interrupting the
transaction logic. The `try...catch` block did accomplish that, but by
putting the status update in a `setTimeout` callback the operation was
made asynchronous.

Transaction status updates now happen unpredictably, in some future
event loop from when they're triggered. This creates a race condition,
where the transaction status update may occur before or after
subsequent state changes. This also introduces a risk of accidentally
undoing a change to the transaction state, as the update made to the
transaction inside the `setTimeout` callback uses a reference to
`txMeta` obtained synchronously before the `setTimeout` call. Any
replacement of the `txMeta` between the `setTxStatus` call and the
execution of the timeout would be erased. Luckily the `txMeta` object
is more often than not mutated rather than replaced, which may explain
why we haven't seen this happen yet.

Everything seems to work correctly with the `setTimeout` call removed,
and now the transaction logic is easier to understand.
2020-05-09 10:46:58 -03:00
..
ens Move export defaults statements alongside their objects (#8525) 2020-05-05 19:49:38 -02:30
network Simplify NetworkController re-export (#8528) 2020-05-05 21:02:44 -02:30
permissions Open notification UI when eth_requestAccounts waits for unlock (#8508) 2020-05-05 07:03:21 -07:00
transactions Synchronously update transaction status (#8563) 2020-05-09 10:46:58 -03:00
ab-test.js Move export defaults statements alongside their objects (#8525) 2020-05-05 19:49:38 -02:30
alert.js Allow disabling alerts (#8550) 2020-05-08 16:45:52 -03:00
app-state.js Minimize inactive timer resets (#8531) 2020-05-05 20:30:50 -03:00
cached-balances.js Move export defaults statements alongside their objects (#8525) 2020-05-05 19:49:38 -02:30
detect-tokens.js Move export defaults statements alongside their objects (#8525) 2020-05-05 19:49:38 -02:30
incoming-transactions.js Move export defaults statements alongside their objects (#8525) 2020-05-05 19:49:38 -02:30
infura.js Move export defaults statements alongside their objects (#8525) 2020-05-05 19:49:38 -02:30
onboarding.js Move export defaults statements alongside their objects (#8525) 2020-05-05 19:49:38 -02:30
preferences.js Move export defaults statements alongside their objects (#8525) 2020-05-05 19:49:38 -02:30
recent-blocks.js Move export defaults statements alongside their objects (#8525) 2020-05-05 19:49:38 -02:30
threebox.js Move export defaults statements alongside their objects (#8525) 2020-05-05 19:49:38 -02:30
token-rates.js Move export defaults statements alongside their objects (#8525) 2020-05-05 19:49:38 -02:30