DEV Community

Cover image for I Built GitHub Hot-Reloading in 3 Seconds (Without Rebuilding the Sandbox) βš‘πŸ§Ÿβ€β™‚οΈ
Harun - solo dev
Harun - solo dev

Posted on

I Built GitHub Hot-Reloading in 3 Seconds (Without Rebuilding the Sandbox) βš‘πŸ§Ÿβ€β™‚οΈ

Rebuilding a cloud sandbox every time you change a single line of code is a terrible developer experience.

It takes 10–15 seconds. It generates a brand new URL. It breaks your flow.

I knew HYNA-Stage needed to be better. So, in v2.7.0, I didn't just add a feature. I engineered a surgical strike on slow deployment cycles.

Welcome to GitHub Hot-Reloading.


⚑ THE MAGIC: hyna-stage watch --github <repo>

When you run this command, HYNA-Stage doesn't tear down your environment and rebuild it from scratch. Instead, it does this:

  1. Smart Polling: The CLI polls the GitHub API for new commits using ETag caching, ensuring we never hit rate limits.
  2. The Surgical Update: When a new commit SHA is detected, it connects to the existing E2B MicroVM.
  3. The Swap: It runs git fetch --depth 1 && git reset --hard, instantly kills the old server process using fuser, and restarts the server using the saved .hyna-start-cmd.

The Result? Your code updates in 3–5 seconds. The URL stays exactly the same. Your browser doesn't even blink. It feels like local development, but it's running in an isolated cloud MicroVM.


πŸ§Ÿβ€β™‚οΈ KILLING ZOMBIE SANDBOXES (The Unsexy but Critical Fix)

On November 11th, I discovered a resource leak. Expired sandboxes were lingering in a "paused" state, quietly consuming resources.

In a real PaaS, this is how you get a $10,000 surprise billing nightmare. So I fixed it with a two-layer defense:

  1. E2B Lifecycle Enforcement: Modified Sandbox.create() to explicitly pass lifecycle: { onTimeout: "kill" }. No more indefinite pausing.
  2. Database Failsafe: Added a pg_cron job (cleanup-stale-envs) that runs hourly. If a sandbox exceeds its TTL + a 10-minute grace period, the database forcefully flips its status to destroyed.

Real founders don't just build cool features; they protect the infrastructure from itself.


πŸ“± THE MOBILE-FIRST REALITY CHECK

Building this entirely on a $150 Android phone in Termux means I feel every single performance bottleneck.

  • OAuth Infinite Redirects: Fixed by removing a single trailing slash from the Supabase Site URL that was causing //oauth/consent pathing errors.
  • Watch Infinite Loops: Replaced the notoriously flaky fs.watch with robust, hash-based MD5 polling.
  • Mobile OOM Crashes: Reduced the html2canvas scale to 1.5 for PDF exports, preventing my phone from running out of memory when generating reports.

If it doesn't run smoothly on my device, it doesn't ship. Period.


πŸ›‘οΈ A QUICK SECURITY LESSON LEARNED

During the development of v2.7.0, I accidentally exposed a Cloudflare API token and a Supabase PAT in my local development logs.

The Fix: I immediately rotated both keys, updated my Termux environment variables, and added a strict reminder to my workflow: Never log secrets, even in "safe" local environments. Security is a habit, not a feature.


πŸ“… THE IIT MADRAS UPDATE

For those following the journey: Yamini from the IIT Madras Incubation Cell replied! She asked for some time to coordinate schedules (their weekends are off, which is completely fair). The meeting is officially in the queue.

While I wait, I keep shipping.


πŸš€ TRY IT YOURSELF

The CLI (@hynaweb/[email protected]) and SDK (@hynaweb/[email protected]) are live on NPM.

npm install -g @hynaweb/stage
hyna-stage login
hyna-stage init node
# Make a change in your GitHub repo and watch the magic happen:
hyna-stage watch --github <your-repo>
Enter fullscreen mode Exit fullscreen mode

🧠 THE TAKEAWAY

You don't need a $3,000 MacBook or a massive DevOps team to build enterprise-grade developer experiences. You need obsession, resourcefulness, and the willingness to dive deep into the unsexy details (like fuser commands and pg_cron jobs).

Thank you to everyone supporting this journey, especially my CTO Akhouri and CMO Nicky.

Keep building. Keep shipping. And never settle for slow reloads. 🐯☁️

β€” Harun, Founder & CEO, HYNAWEB

Top comments (24)

Collapse
 
koda2026 profile image
Harun - solo dev •

@effessdev bro!!

Collapse
 
effessdev profile image
EffessDev •

What?

Collapse
 
koda2026 profile image
Harun - solo dev •

Bro what do you think

Thread Thread
 
effessdev profile image
EffessDev •

Good! πŸ‘

Thread Thread
 
koda2026 profile image
Harun - solo dev •

Just? Good hah

Thread Thread
 
effessdev profile image
EffessDev •

Not just "Good" but "Good" with an exclamation mark and a thumbs up emoji!

Thread Thread
 
koda2026 profile image
Harun - solo dev •

Broo Is Joking Lol So Apparently To A Dev Especially Esp-32 Dev A Syntax Mismatch Is A Problem πŸ˜‚πŸ˜‚πŸ˜‚πŸ˜‚πŸ€£πŸ€£πŸ€£πŸ€£πŸ€£

Thread Thread
 
effessdev profile image
EffessDev •

It makes a BIG difference.

Thread Thread
 
koda2026 profile image
Harun - solo dev •

Bro ESP-32 and javascript and python is brothers they are just stubborn case sensitive 🀣🀣

Thread Thread
 
effessdev profile image
EffessDev •

Yeah πŸ˜‚

Thread Thread
 
koda2026 profile image
Harun - solo dev •

Bro and i know the pain because in my code i had a situation to change code manually and i accidentally changed the function name to " Deploystage() "instead of " deploystage() " Lol i was wondering for a whole day and i was like πŸ‘πŸ‘„πŸ‘ 🀣🀣🀣🀣

Thread Thread
 
effessdev profile image
EffessDev •

Me too accidentally used the wrong case for a Postgres table name in a query lol. Same reaction when I noticed the issue 😭 I think in my case it was well over one day

Collapse
 
hubedav profile image
David •

That bump in speed with updates and killing off zombie processes are great housekeeping things to address early (like you did)!

I'm absolutely stoked for you to hear your talks are happening! I'm looking forward to hearing how it goes.

You have a unique built-in performance check by building, and using, your platform from your phone. It's incredibly frustrating using tools and platforms that're clearly not tested for not-top-end hardware.

Collapse
 
koda2026 profile image
Harun - solo dev •

Thank you, David! πŸ™

You nailed it with the word "housekeeping." It’s so tempting to just chase the shiny new features, but you and I both know that a platform is only as good as its ability to clean up after itself and not bankrupt the founder.

And you are 100% right about the hardware constraint. Building and testing on this $150 phone is my ultimate reality check. If a tool is too heavy or poorly optimized for my device, I know it will be terrible for students and indie hackers with similar setups. It forces me to write lean, efficient code.

Thank you for always reading the details and for the incredible support. I will definitely keep you posted on how the IIT Madras talks go! 🐯☁️

Collapse
 
onelifevibe profile image
OneLifeVibe •

The zombie sandbox fix stood out to me more than the 3 second reload. Passing lifecycle onTimeout kill at creation, plus the hourly pg_cron cleanup with a TTL and a 10 minute grace period, is the kind of guardrail that stops a forgotten environment from turning into a surprise bill. The surgical update is smart too: polling with ETag caching so the watch does not hammer the API, then fetching and resetting in the existing MicroVM while keeping the same URL. Building and testing all of this on a phone in Termux makes the performance discipline real. How did you settle on the 10 minute grace period, and did the MD5 polling replace fs.watch for the GitHub watch path as well, or only for local file changes?

Collapse
 
koda2026 profile image
Harun - solo dev •

Good morning! Thank you for such a sharp, detailed read of the article. It means a lot when senior devs catch the nuance in the unsexy stuff. πŸ™

To answer your questions:

1. The 10-Minute Grace Period:
This was a calculated balance between user safety and cost control. E2B sandbox teardown isn't always instantaneous, and there can be slight clock drift or network latency between the client, Supabase, and the E2B control plane. A 10-minute buffer ensures that if a user's session just expired but they are actively saving their last changes, we don't aggressively nuke their work mid-operation. However, 10 minutes is short enough that even in a worst-case "rogue process" scenario, it won't trigger a meaningful billing spike. It’s the sweet spot.

2. MD5 Polling vs. ETag Polling:
Great catch! They serve two different paths:

  • Local File Changes (hyna-stage watch): I completely replaced fs.watch with MD5 hash-based polling. fs.watch is notoriously flaky, especially in Termux/Deno environments, and would sometimes trigger infinite loops or miss events. MD5 polling is bulletproof and cross-platform.
  • GitHub Watch (hyna-stage watch --github): For this, we don't touch the local file system watcher at all. Instead, the CLI polls the GitHub REST API for new commit SHAs using ETag caching. This ensures we get instant updates without hammering the GitHub API or triggering rate limits.

Building on a $150 phone forces you to be ruthless about performance and reliability. There is no room for flaky watchers or memory leaks!

Thanks again for the fantastic questions. Keep an eye out, v3.0.0 is right around the corner! 🐯☁️⚑

Collapse
 
effessdev profile image
EffessDev •

Right when I was about to go to bed πŸ›οΈπŸ˜΄

Collapse
 
koda2026 profile image
Harun - solo dev •

Broo

Collapse
 
star123 profile image
Sᴛᴀʀ⭐ •

Cool πŸ˜ƒ

Collapse
 
star123 profile image
Sᴛᴀʀ⭐ • • Edited

Bro your github link? πŸ˜ƒ

Collapse
 
koda2026 profile image
Harun - solo dev •

Hey! Thanks so much! πŸ˜ƒ

Here is the GitHub repo where all the magic (and the messy Termux debugging) happens:
πŸ”— github.com/harun-sket/hyna-stage

Feel free to star it, open an issue if you find any bugs, or just let me know what you think of the code. Always happy to chat with fellow builders! πŸš€

Collapse
 
koda2026 profile image
Harun - solo dev •

@akhourianmolkumar bro what do you think ❀‍πŸ”₯

Collapse
 
koda2026 profile image
Harun - solo dev •

@technogamerz hey didi long time no speak

Collapse
 
technogamerz profile image
π“π‘πž π‹πšπ³π² 𝐆𝐒𝐫π₯ •

Sorry bro, how are you? :D