잡담··3 min read

I Was Debugging in My Dreams

Woke up at 3:47 AM, opened my laptop, and the bug from my dream was real

Eyes Open at 3:47 AM

I had a dream. In the dream, I was sitting at my office monitor. A red error message on screen: TypeError: Cannot read properties of undefined (reading 'map'). I opened the console and checked the data, but it kept changing. Array, then null, then a number. Dreams are illogical, obviously, but dream-me was dead serious about debugging.

I woke up. 3:47 AM. "Wait, doesn't that error actually exist?" I'd submitted a PR before leaving work, and a creeping feeling that I'd missed an edge case washed over me.

I Opened the Laptop

Debated for 5 minutes under the covers. "I can check tomorrow at work." But I couldn't fall back asleep. The anxiety. So I opened the laptop and pulled up the code.

const items = data?.results?.map(item => item.name);

That line. Optional chaining on data?.results, but I hadn't considered the case where results isn't an empty array but undefined entirely. The API sometimes omits the results key when there are no results. The dream error was real. (Not identical, but the same category of problem.)

Fix was simple. Add ?? [] after data?.results?.map(...) or handle the branch above. Done in 3 minutes.

But should I have been doing this at 3:47 AM? No.

This Isn't the First Time

Looking back, I've coded in dreams more than a few times.

Incident 1. Third year, during a major refactoring period. Dream featured git merge conflict resolution. Endless conflicts -- fix one, another appears. Woke up sweating.

Incident 2. Night before a deployment. Dreamed the production server went down. Dashboard with red spikes. Next day's deploy went fine. The dream was just anxiety manifesting.

Incident 3. This time. The only instance where the dream-bug was actually real.

Why Am I Coding in My Sleep?

Psychologically, dreams are the brain processing information it couldn't handle during the day. Developers think about code constantly while awake, so it showing up in dreams makes sense.

But the problem: if I'm coding in dreams, the brain never rests. I'm working while sleeping. Sleep quality suffers inevitably.

Asked my teammates. "Has this happened to you?" 4 out of 6 said yes. More common than I thought. One colleague said "I was writing regular expressions in my dream." That's genuinely unsettling.

This Might Be a Burnout Signal

Waking at 3 AM to check code is not normal. Don't frame it as "dedication." Not being able to let go of work after leaving the office means the boundary has collapsed.

Overtime has been heavy recently. Tight deployment schedule meant staying until 9 PM at least three times a week. During this period, dream-coding frequency increased. The correlation seems clear.

What I'm Trying

Attempting to not look at code after work. Turn off Slack notifications after leaving. (But I check occasionally. Habits die hard.) Trying to avoid tech content before bed. YouTube's algorithm pushes coding videos -- scrolling past is difficult.

Most effective: reading fiction before sleep. 20 minutes of a novel on Kindle transitions the brain from code-mode to story-mode. Nights after reading fiction seem to have fewer coding dreams. (Anecdotal, no data.)

About That PR

Next morning at work, I updated the PR. One additional commit. Nobody flagged that issue in code review. Might have been merged as-is if I hadn't caught it.

But my dream caught it. Should I be grateful or worried? Probably both.

Today is Friday. Going hiking this weekend. On hiking days, I don't code in my dreams. When the body is exhausted, the brain apparently can't spare cycles for debugging.

Related Posts