Volume 9

Q412: Implementation Drill Adding Output Caps and Run Identifiers

Difficulty: SeniorFrequency: MediumAnswer time: 18-22 minutes

What Interviewers Want To Evaluate

This drill tests whether you can make a browser execution tool safer without making it heavy.

Console capture is useful, but uncontrolled output can freeze the UI or make results hard to read.

Run identifiers also prevent older executions from confusing the current output.

Short Interview Answer

I would add a run id for every execution and cap console output by entry count and message length. If output exceeds the cap, the console should show a clear truncation message. Run ids help separate current output from stale output and make future stop or retry behavior easier to reason about.

Why Output Caps Matter

User code can produce:

thousands of logs
large nested objects
repeated errors
accidental loops
long strings

Even in a learning tool, output needs limits.

The user should recover from mistakes quickly.

Run ID Model

Each run can have:

runId
startedAt
status
console entries
endedAt

The UI may not show all fields immediately.

But the model helps keep output honest.

Output Cap Rules

Define:

max console entries
max message length
max execution time

Example:

100 log entries
4000 characters per entry
3 second timeout

The exact numbers can change.

The guardrail matters.

Truncation Message

Show:

Output stopped after 100 entries.
Reduce logging or narrow the loop.

This message teaches the user what happened.

It is better than silently dropping output.

UI Impact

Add:

run status
entry count
truncated indicator
clear console action
copy visible output

Avoid cluttering the first version.

The most important thing is that the console stays usable.

Testing Plan

Test:

normal output
large output capped
long message truncated
timeout output
new run clears or separates old output
copy output after truncation

These tests protect the browser from accidental overload.

Common Mistakes

  • Letting output grow forever.
  • Truncating silently.
  • Mixing old and new run output.
  • Copying hidden internal output instead of visible output.
  • Adding run ids internally but never using them.

Final Mental Model

Execution output needs:

identity
limits
clear truncation
recovery
copyable visible output

Safety can be simple and still meaningful.