Browser Developer Tools
Loading the Extension for Debugging
Build in Development Mode
Build the extension with source maps enabled:This enables inline source maps for easier debugging.
Load Extension in Chrome
- Open Chrome and navigate to
chrome://extensions/ - Enable “Developer mode” in the top right
- Click “Load unpacked”
- Select the
packages/extension-koni/builddirectory
Debugging the Background Script
The background environment (background.ts) handles all API calls, state management, and message processing.
Open Background Page DevTools
Chrome:
- Go to
chrome://extensions/ - Find SubWallet in the list
- Click “background page” or “service worker” link
- DevTools will open for the background context
- Go to
about:debugging#/runtime/this-firefox - Find SubWallet
- Click “Inspect”
Set Breakpoints
In the DevTools Sources tab:
- Navigate to
background.tsor related files - Click line numbers to set breakpoints
- Trigger actions in the extension to hit breakpoints
Debugging the Extension UI (Popup)
The popup is the main UI that appears when clicking the extension icon.Open Popup DevTools
- Right-click on the extension popup
- Select “Inspect” or “Inspect Element”
- DevTools opens for the popup context
Debug React Components
Install React Developer Tools:Then:
- Open popup DevTools
- Switch to “Components” tab
- Inspect React component tree and props
Debug Redux State
Install Redux DevTools:Access the Redux tab to:
- View current state
- Track actions
- Time-travel debug state changes
Debugging Injected Scripts
Injected scripts run in web pages to provide wallet functionality to dApps.Debugging Message Passing
SubWallet uses Chrome’s message passing API for communication between components.Message Flow
Debug Message Handlers
Add logging to track message flow:Common Message Types
Debugging Storage
Inspect and modify Chrome storage data.View Storage Contents
In DevTools Console:Clear Storage
Monitor Storage Changes
Source Maps
Enable source maps for better debugging experience:Development Build with Source Maps
-d inline-source-map) to the webpack build.
Navigate Original Source
With source maps enabled:- DevTools shows original TypeScript files
- Breakpoints work in
.tsfiles instead of bundled.js - Stack traces reference original source locations
Common Issues
Extension Not Loading
Symptoms: Extension doesn’t appear in browser toolbar or crashes on load Solutions:Messages Not Being Received
Symptoms: UI doesn’t update, background doesn’t respond Solutions:-
Verify message type format:
-
Check handler exists:
Ensure message type is defined in
KoniRequestSignaturesand has a handler inKoniExtensionorKoniTabs. -
Add debug logging:
State Not Persisting
Symptoms: Extension state resets after browser restart Solutions:-
Verify store initialization:
-
Check Chrome storage permissions:
Verify
manifest.jsonincludes: -
Monitor storage writes:
Cron Jobs Not Running
Symptoms: Periodic updates not happening Solutions:-
Check cron initialization:
Verify cron jobs are registered in
KoniCron.init() -
Add logging:
- Verify background persistence: Ensure background script stays alive (Manifest V2) or uses service worker correctly (Manifest V3)
Hot Reload Not Working
Symptoms: Changes don’t appear after rebuilding Solutions:-
Manually reload extension:
- Chrome: Go to
chrome://extensions/and click reload icon - Firefox: Go to
about:debuggingand click reload
- Chrome: Go to
-
Use watch mode:
- Hard refresh popup: Close and reopen the popup, or press Ctrl+R while popup is focused
Performance Debugging
Profile Background Script
- Open background page DevTools
- Go to Performance tab
- Click Record
- Perform actions in extension
- Stop recording
- Analyze flame chart for bottlenecks
Monitor Memory Usage
- Open DevTools Memory tab
- Take heap snapshot
- Perform actions
- Take another snapshot
- Compare to identify memory leaks
Network Monitoring
- Open Network tab in background DevTools
- Monitor API calls
- Check request/response times
- Identify slow or failing requests
Debugging Tools
Essential Browser Extensions
- React Developer Tools - Inspect React components
- Redux DevTools - Debug Redux state
- JSON Viewer - Format JSON responses
Logging Best Practices
Use structured logging:Remote Debugging
For debugging on other devices:Android Chrome
- Enable USB debugging on Android device
- Connect device to computer
- Open
chrome://inspectin desktop Chrome - Select device and inspect
iOS Safari (limited support)
- Enable Web Inspector on iOS device
- Connect to Mac
- Open Safari > Develop > [Device Name]