Skip to content

Commit

Permalink
Web Store Minor Logging and Error Handling Improvements for Account C…
Browse files Browse the repository at this point in the history
  • Loading branch information
dagarcia7 authored Jan 13, 2025
1 parent 7a663e4 commit e9374a0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 23 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

### Fixes

* Web Store Minor Logging and Error Handling Improvements (#656).
* Web Store InsertChainMmrNodes Duplicate Ids Causes Error (#627).
* Fixed client bugs where some note metadata was not being updated (#625).
* Added Sync Loop to Integration Tests for Small Speedup (#590).
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 12 additions & 19 deletions crates/rust-client/src/store/web_store/js/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ export async function getAccountHeader(accountId) {
.toArray();

if (allMatchingRecords.length === 0) {
console.log("No records found for given ID.");
return null; // No records found
console.log("No account header record found for given ID.");
return null;
}

// Convert nonce to BigInt and sort
Expand Down Expand Up @@ -114,7 +114,6 @@ export async function getAccountHeader(accountId) {
};
return AccountHeader;
} catch (error) {
console.error("Error fetching most recent account record:", error);
throw error; // Re-throw the error for further handling
}
}
Expand All @@ -128,8 +127,8 @@ export async function getAccountHeaderByHash(accountHash) {
.toArray();

if (allMatchingRecords.length === 0) {
console.log("No records found for given hash.");
return null; // No records found
console.log("No account header record found for given hash.");
return null;
}

// There should be only one match
Expand All @@ -154,7 +153,6 @@ export async function getAccountHeaderByHash(accountHash) {
};
return AccountHeader;
} catch (error) {
console.error("Error fetching most recent account record:", error);
throw error; // Re-throw the error for further handling
}
}
Expand All @@ -169,7 +167,7 @@ export async function getAccountCode(codeRoot) {

if (allMatchingRecords.length === 0) {
console.log("No records found for given code root.");
return null; // No records found
return null;
}

// The first record is the only one due to the uniqueness constraint
Expand All @@ -185,7 +183,6 @@ export async function getAccountCode(codeRoot) {
code: codeBase64,
};
} catch (error) {
console.error("Error fetching code record:", error);
throw error; // Re-throw the error for further handling
}
}
Expand All @@ -200,7 +197,7 @@ export async function getAccountStorage(storageRoot) {

if (allMatchingRecords.length === 0) {
console.log("No records found for given storage root.");
return null; // No records found
return null;
}

// The first record is the only one due to the uniqueness constraint
Expand All @@ -215,7 +212,6 @@ export async function getAccountStorage(storageRoot) {
storage: storageBase64,
};
} catch (error) {
console.error("Error fetching code record:", error);
throw error; // Re-throw the error for further handling
}
}
Expand All @@ -230,7 +226,7 @@ export async function getAccountAssetVault(vaultRoot) {

if (allMatchingRecords.length === 0) {
console.log("No records found for given vault root.");
return null; // No records found
return null;
}

// The first record is the only one due to the uniqueness constraint
Expand All @@ -246,7 +242,6 @@ export async function getAccountAssetVault(vaultRoot) {
assets: assetsBase64,
};
} catch (error) {
console.error("Error fetching code record:", error);
throw error; // Re-throw the error for further handling
}
}
Expand All @@ -260,7 +255,7 @@ export async function getAccountAuth(accountId) {
.toArray();

if (allMatchingRecords.length === 0) {
console.log("No records found for given account ID.");
console.log("No account auth records found for given account ID.");
return null; // No records found
}

Expand All @@ -277,7 +272,6 @@ export async function getAccountAuth(accountId) {
auth_info: authInfoBase64,
};
} catch (err) {
console.error("Error fetching account auth:", err);
throw err; // Re-throw the error for further handling
}
}
Expand Down Expand Up @@ -311,7 +305,7 @@ export async function fetchAndCacheAccountAuthByPubKey(accountId) {
.toArray();

if (allMatchingRecords.length === 0) {
console.log("No records found for given account ID.");
console.log("No account auth records found for given account ID.");
return null; // No records found
}

Expand All @@ -334,7 +328,6 @@ export async function fetchAndCacheAccountAuthByPubKey(accountId) {
auth_info: authInfoBase64,
};
} catch (err) {
console.error("Error fetching account auth by public key:", err);
throw err; // Re-throw the error for further handling
}
}
Expand All @@ -353,7 +346,7 @@ export async function insertAccountCode(codeRoot, code) {
};

// Perform the insert using Dexie
await accountCodes.add(data);
await accountCodes.put(data);
} catch (error) {
console.error(`Error inserting code with root: ${codeRoot}:`, error);
throw error; // Rethrow the error to handle it further up the call chain if needed
Expand All @@ -371,7 +364,7 @@ export async function insertAccountStorage(storageRoot, storageSlots) {
};

// Perform the insert using Dexie
await accountStorages.add(data);
await accountStorages.put(data);
} catch (error) {
console.error(`Error inserting storage with root: ${storageRoot}:`, error);
throw error; // Rethrow the error to handle it further up the call chain if needed
Expand All @@ -389,7 +382,7 @@ export async function insertAccountAssetVault(vaultRoot, assets) {
};

// Perform the insert using Dexie
await accountVaults.add(data);
await accountVaults.put(data);
} catch (error) {
console.error(`Error inserting vault with root: ${vaultRoot}:`, error);
throw error; // Rethrow the error to handle it further up the call chain if needed
Expand Down
17 changes: 14 additions & 3 deletions crates/web-client/test/mocha.global.setup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,20 @@ before(async () => {
shell: process.platform == "win32",
});

browser = await puppeteer.launch({ headless: true, protocolTimeout: 360000 });
testingPage = await browser.newPage();
await testingPage.goto(TEST_SERVER);
try {
browser = await puppeteer.launch({
headless: true,
protocolTimeout: 360000,
});
testingPage = await browser.newPage();
await testingPage.goto(TEST_SERVER);
} catch (error) {
console.error("Failed to launch Puppeteer:", error);
if (serverProcess && !serverProcess.killed) {
serverProcess.kill("SIGTERM");
}
throw error;
}

if (env.DEBUG_MODE) {
testingPage.on("console", (msg) => console.log("PAGE LOG:", msg.text()));
Expand Down

0 comments on commit e9374a0

Please sign in to comment.