Skip to content

Comments

Refactor promise chains to async/await syntax#29

Open
Copilot wants to merge 4 commits intomasterfrom
copilot/refactor-code-async-await
Open

Refactor promise chains to async/await syntax#29
Copilot wants to merge 4 commits intomasterfrom
copilot/refactor-code-async-await

Conversation

Copy link

Copilot AI commented Feb 10, 2026

Modernizes promise-based operations across 12 files, replacing .then()/.catch() chains with async/await for improved readability and error handling.

Changes

Core refactorings:

  • useEffect hooks: Wrapped async operations in named functions with void invocation
  • Event handlers: Used void (async () => {...})() IIFE pattern for fire-and-forget operations
  • Error boundaries: Replaced .catch() with try/catch blocks

Example transformation:

// Before
useEffect(() => {
  fetchCast({ type, identifier })
    .then((result) => {
      if (result) setData(result);
    })
    .catch((error) => {
      logError(error, 'Failed to load Cast');
    });
}, [identifier, logError, type]);

// After
useEffect(() => {
  async function loadCast() {
    try {
      const result = await fetchCast({ type, identifier });
      if (result) setData(result);
    } catch (error) {
      logError(error, 'Failed to load Cast');
    }
  }
  void loadCast();
}, [identifier, logError, type]);

Files modified:

  • libs/base-ui/contexts/Experiments.tsx
  • apps/web/src/hooks/useSetPrimaryBasename.ts
  • apps/web/src/components/ImageCloudinary/index.tsx
  • apps/web/src/components/NeynarCast/index.tsx
  • apps/web/src/components/Basenames/* (5 files)
  • apps/web/src/components/ConnectWalletButton/CustomWalletAdvancedAddressDetails.tsx
  • apps/web/src/components/ThreeHero/DynamicRigidBody.tsx
  • apps/web/src/utils/logger.ts

Note: Next.js dynamic() imports remain unchanged—they already use async/await correctly.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • fonts.googleapis.com
    • Triggering command: /opt/hostedtoolcache/node/24.13.0/x64/bin/node /opt/hostedtoolcache/node/24.13.0/x64/bin/node /home/REDACTED/work/web/web/apps/web/node_modules/next/dist/bin/next build (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Refactor code to use async/await for promise-based operations. Ensure that all instances of .then() and .catch() are replaced with async/await syntax. Update error handling to be robust and modern. Provide comments and follow JavaScript best practices throughout. Target the master branch.

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: Kushmanmb <193178375+Kushmanmb@users.noreply.github.com>
try {
await bugsnagNotify(message, (e) => e.addMetadata('baseweb', { meta }));
} catch (e) {
console.error('Error reporting to Bugsnag', e);

Check failure

Code scanning / Bearer

Leakage of information in logger message Error

Leakage of information in logger message
Copilot AI and others added 2 commits February 10, 2026 14:47
Co-authored-by: Kushmanmb <193178375+Kushmanmb@users.noreply.github.com>
Co-authored-by: Kushmanmb <193178375+Kushmanmb@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor code to use async/await for promise operations Refactor promise chains to async/await syntax Feb 10, 2026
void (async () => {
try {
const result = await initiateReclaim(reclaimContract);
console.log({ result });

Check failure

Code scanning / Bearer

Leakage of information in logger message Error

Leakage of information in logger message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants