The bug only existed on the screen nobody tested: a win screen that would not move on.
Hushabye Bay is a small browser arcade game: you tap the water to drop hush-pods, a seal collects them, and a shift runs on a timer. Clear a shift and a "next shift" button appears. Players were finishing shift one, tapping that button, and nothing happened. The game looked frozen. They closed the tab.
The console told the story in one line: ReferenceError: data is not defined.
What was actually wrong
The button handler read two saved values for a bonus timer:
function handleShiftDoneTap(p) {
if (hitNextShift(p)) {
var at = data['hb-lamp-at'];
var bonus = data['hb-lamp-bonus'];
advanceShift();
}
}
data looks like it belongs to the game. It does not. It only ever existed as the parameter of the storage callback that runs once at startup:
window.Portal.init(function () {
window.Portal.storageGet([...], function (data) {
// data lives here, and only here
});
});
So in the button handler data is an undeclared identifier. The throw happens before advanceShift() runs, which is why the screen stayed exactly where it was. Nothing was wrong with the shift logic, the score, or the save. One variable was read in a scope where it never existed.
Why it survived testing
Every test I ran started a shift and stopped. The path that breaks is: play well enough to finish a shift, then continue. That is the path a real player takes first, and it is the path a "does it boot and render" test never walks.
A static scan caught it faster than any play session. An eslint run with no-undef over the whole file listed the exact line. Two false positives elsewhere (the browser's own confirm()) and one real hit: this one. If a game is a handful of plain script files, that scan is a two-second check worth running before every upload.
The fix, and what came with it
The handler now reads the bonus state from the game's own saved meta object, the same one the menu uses, so there is one source of truth instead of a startup closure that leaks into a tap handler.
While in there I fixed a second bug of the same family: the moon-lantern bonus granted 15 extra seconds, but the value was recomputed every frame from a stale base, so it was overwritten before it ever reached the clock. It now applies once and stays applied.
And since a player who wins should not have to hunt for a button, a won shift now counts down three seconds and starts the next one by itself, carrying the score over. A tap skips the countdown, the menu is still one tap away, and the first shift of a session is 90 seconds instead of 60 so a new player gets a full round to learn the controls.
The takeaway
A win screen is not a cosmetic state. It is the one place where a small scoping mistake is guaranteed to be hit by the players who are enjoying the game most, and it is the state least likely to be in a smoke test. Walk the full loop, not the first ten seconds of it.
The fixed build is live and free to play in the browser: https://playgama.com/game/36omjfj4xbgnro
Top comments (0)