-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Campaign shows "Error Loading Campaign" immediately after creation despite successful transaction
Description
After creating a campaign and completing the wallet transaction, users are redirected to their newly created campaign page. However, the page shows "Error Loading Campaign" instead of the campaign details. The campaign is successfully created and can be accessed by navigating manually through "My Campaigns" after a few seconds.
Steps to Reproduce
- Navigate to campaign creation page
- Fill out campaign details
- Submit the form and complete the wallet transaction
- Observe the redirect to /campaign/[id]
Expected: Campaign page loads with campaign details
Actual: "Error Loading Campaign" error is displayed
Workaround: Navigate to home page → My Campaigns → Click on the campaign (works after ~5-10 seconds)
Root Cause Analysis
This is a race condition between blockchain transaction confirmation and indexer data availability.
Sequence of events:
- User submits campaign creation form
- campaignsContractClient.create_campaign() executes on blockchain
- Contract returns campaign object with ID (e.g., id: 123)
- Code immediately redirects: router.push('/campaign/123') (src/entities/campaign/hooks/forms.ts:353)
- CampaignBanner component mounts and calls indexer.useCampaign({ campaignId: 123 })
- Indexer returns 404 because the blockchain transaction hasn't been indexed yet (indexing typically takes 2-5+ seconds)
- User sees "Error Loading Campaign" (src/entities/campaign/components/CampaignBanner.tsx:82)
Why manual navigation works later:
- By the time the user navigates back and clicks on "My Campaigns", several seconds have passed
- The indexer has processed the transaction
- The API returns the campaign data successfully