Skip to main content
Problems that may occur during HMR usage and practical solutions.

Changes Not Reflected

Situation

Saved but still getting isActive is not a function error on API call.

Cause 1: Using Static Import

There’s likely a static import of UserModel somewhere. How to check:
Solution: Change to dynamic import
Sonamu’s Syncer automatically handles dynamic imports for Entity-based files, so this problem doesn’t occur in typical Model/API files. It mainly occurs in custom scripts or initialization code.

Cause 2: Error Hidden in Console

An error may have occurred during HMR but you missed it. How to check: Scroll through the terminal to check for errors like:
Solution: Check the file and line number in the error message and fix it.

Cause 3: Cache Corruption

Rarely, ESM cache may not be completely removed. Solution: Server restart

”File not imported dynamically” Error

Situation

Cause

A Boundary file (user.model.ts) was loaded via static import somewhere.

Quick Fix

Option 1: Change static import to dynamic import (Recommended) Find the file mentioned in the error message:
Option 2: Exclude the file from Boundary If you really can’t change to dynamic import:
Option 3: Ignore the error (Not recommended)
Using Option 3 means HMR won’t work for that file. Not recommended as it significantly reduces development convenience.

Memory Increase on Reload

Situation

Cause

Resources from previous modules (timers, event listeners, connections, etc.) aren’t cleaned up, causing leaks. How to check:

Solution

Clean up resources with import.meta.hot.dispose(): Example 1: Timers
Example 2: WebSocket
Example 3: Event Listeners
Example 4: Database Connection Pool

API Registered Multiple Times

Situation

Server log shows warnings about the same API being registered multiple times.

Cause

Existing APIs weren’t removed when Model file was reloaded.

Check

Check if API removal is shown in Syncer logs:

Solution

Syncer normally handles this automatically, but if problem persists: 1. Server restart
2. Check Syncer logic (rare cases)
If this logic isn’t executing, it may be a Sonamu bug. Please report to GitHub Issues.

Circular Dependency Issues

Situation

HMR gets stuck in infinite loop or some modules don’t load.

Cause

Circular reference between Models:

Solutions

Option 1: Import only types (Recommended)
Option 2: Separate common types file
Option 3: Redesign dependency direction

HMR Not Working for Specific Files

Situation

Cause 1: Not Matching Boundary Pattern

Check:
Fix:

Cause 2: File Not Imported

HMR only tracks files that are actually imported. Check:
Fix: Import the file somewhere, or delete it if not needed.

SSR File Changes Not Reloading

Situation

Cause

SSR files are handled specially.

Fix

Syncer automatically handles SSR file changes, but if manual reload is needed:
Or in code:

HMR Too Slow

Situation

Cause

Dependency tree is too deep or wide, invalidating many files. Check:

Solutions

1. Minimize imports
2. Optimize library imports like lodash
3. Reduce Boundary scope

Debugging Tips

Enable HMR Logs

To see detailed HMR operation:
Output example:

Check Dependency Tree

Track Invalidated Files

Pay close attention to logs Syncer prints to console:

Monitor Memory Usage

Last Resort: Full Restart

When all solutions fail:

Getting Help

If the problem still isn’t resolved:

1. Report to GitHub Issues

Create a new issue at: https://github.com/cartanova-ai/sonamu/issues

2. Include the Following Information

Please provide this information for problem resolution:
  • Sonamu version (package.json)
  • Node.js version (node -v)
  • Error message that occurred
  • Minimal reproducible example
  • HMR logs (DEBUG=hmr-hook:* pnpm dev)

3. Include File Structure Example

Clearly show the file structure where the problem occurs:
Please include an example description:
Detailed descriptions like this help you get faster responses!