bugbear debugging
2022-06-21 17:54It is commonly believed that when dealing with an ornery bug, just explaining the problem out loud to someone else often grants insight. "--oh, I see it now, sorry to bother you." So much so that, supposedly, one senior engineer required juniors to explain their problem first to a teddy bear, the 'bug bear', and only if that failed could they bother him.
I haven't actually used this much. Mostly been on my own, and my default approach to bugs is more logging. But I was playing with TypeScript and Koa today, and had a problem that didn't work for: the main code worked fine, but if authentication failed, the server seemed to never respond to the caller.
I was about to find a senior active on Slack, to ask for help, when I thought of the bugbear. I did not have a teddy bear, and I don't think I even said anything out loud, but I did go line by line, trying to mentally verbalize what was happening and what the point was. And yes, found something suspicious: "ctx.response = 401", which looks like it's trying to set a status code but is clobbering the response object. And yes, "cts.response.status = 401" fixed it. Voila! No seniors disturbed.
I haven't actually used this much. Mostly been on my own, and my default approach to bugs is more logging. But I was playing with TypeScript and Koa today, and had a problem that didn't work for: the main code worked fine, but if authentication failed, the server seemed to never respond to the caller.
I was about to find a senior active on Slack, to ask for help, when I thought of the bugbear. I did not have a teddy bear, and I don't think I even said anything out loud, but I did go line by line, trying to mentally verbalize what was happening and what the point was. And yes, found something suspicious: "ctx.response = 401", which looks like it's trying to set a status code but is clobbering the response object. And yes, "cts.response.status = 401" fixed it. Voila! No seniors disturbed.