fix: a popup reload no longer logs the requests it cancels on most screens (closes #475)
check / check (push) Waiting to run
e2e / e2e-chrome (push) Waiting to run
e2e / e2e-firefox (push) Waiting to run

The transaction lists and ENS name lookups on the address and token
screens, the address scan after a wallet is created, the endpoint checks
in Settings, the wait screen's receipt check, the Send screen's Max fee
estimate and the token lookup on both add-token screens now check the
signal the popup aborts on pagehide before reporting a failed request.
scanForAddresses(), resolveEnsNames() and lookupTokenInfo() take the
signal.

End-to-end tests reload the popup on the address screen and during the
address scan with their requests held. Jest tests show each of these
reports a real failure and stays silent once the popup has closed. The
transaction detail and confirmation screens are left out: they discard
the popup context that carries the signal.

Model: opus-5-5
This commit was merged in pull request #477.
This commit is contained in:
2026-10-06 22:09:08 +02:00
parent cb23611a17
commit ad1b4f0557
21 changed files with 762 additions and 49 deletions
+51 -2
View File
@@ -65,7 +65,7 @@ jest.mock("../src/shared/log", () => ({
debugf: () => {},
infof: () => {},
warnf: () => {},
errorf: () => {},
errorf: jest.fn(),
},
// The explorer's token list, which refreshBalances() also fetches.
debugFetch: jest.fn(async () => ({
@@ -143,6 +143,7 @@ const { Transaction, Wallet, formatEther } = require("ethers");
const { refreshBalances } = require("../src/shared/balances");
const { encryptWithPassword } = require("../src/shared/vault");
const { state } = require("../src/shared/state");
const { log } = require("../src/shared/log");
const send = require("../src/popup/views/send");
const confirmTx = require("../src/popup/views/confirmTx");
@@ -226,10 +227,16 @@ function tokenRow(value, decimals = "18") {
// The confirmation screen Review leads to, once shown.
let confirmed = null;
// Stands in for the popup's: aborting it is the popup closing.
let pageClosed;
// Open the Send screen for `token` ("ETH" or a token address), with the
// recipient entered.
function openSend(token = "ETH") {
send.init({ showConfirmTx: (info) => (confirmed = info) });
send.init({
showConfirmTx: (info) => (confirmed = info),
pageClosed: pageClosed.signal,
});
confirmTx.init({});
send.resetSendValidation();
state.currentView = "send";
@@ -260,6 +267,8 @@ function canSend() {
beforeEach(() => {
elements.clear();
log.errorf.mockClear();
pageClosed = new AbortController();
confirmed = null;
state.selectedToken = null;
state.trackedTokens = [];
@@ -447,6 +456,46 @@ describe("Max on an ETH send", () => {
expect(text("flash-msg")).toBe("");
});
// Holds the node's fee answer until the returned function fails it, as a
// node that cannot be reached, or a request the popup's closing
// cancelled, does.
function holdFailingFeeEstimate() {
let fail;
mockNode.feeData = new Promise((_, reject) => {
fail = () => reject(new TypeError("Failed to fetch"));
});
return fail;
}
test("reports a fee estimate that fails while the popup is open", async () => {
await refreshWith(BALANCE_WEI);
openSend();
const fail = holdFailingFeeEstimate();
const pressed = pressMax();
fail();
await pressed;
expect(log.errorf).toHaveBeenCalledWith(
"max amount fee estimate failed:",
"Failed to fetch",
);
expect(text("flash-msg")).toBe(
"The network fee could not be estimated.",
);
});
// https://git.eeqj.de/sneak/AutistMask/issues/475
test("does not report a fee estimate that fails once the popup has closed", async () => {
await refreshWith(BALANCE_WEI);
openSend();
const fail = holdFailingFeeEstimate();
const pressed = pressMax();
pageClosed.abort();
fail();
await pressed;
expect(log.errorf).not.toHaveBeenCalled();
expect(el("send-amount").value).toBe("");
});
test("fills in once the held fee estimate arrives with nothing changed", async () => {
await refreshWith(BALANCE_WEI);
openSend();