Weekly Retrospective: The Last Week of September

I haven’t written a weekly retrospective in a while. I tend to burn out fairly often, and that happened again. I was also wondering whether weekly retrospectives were necessary. After going without them for a while, I felt the need, so here I am starting again.

In these retrospectives, I mostly organize the issues I encountered at work that week and the things I learned, and use the time to reset my direction.

Make asking “why” a habit.

During my first year, I was so busy tackling whatever work came my way that CS knowledge and understanding how things worked felt like luxuries. I was just glad if I somehow patched up an error. But now I’m almost in my third year! I have more breathing room at work, and I’m increasingly realizing that solving problems at their root requires deeper understanding. I can’t keep muddling through like this. Why did this error happen? Why does React work this way? Let’s really think about it.

Open Source Contribution Academy

I became interested in open source and was wondering how to get started when I happened to see a recruitment post. It seemed like a wonderful first experience, so I joined. The project I’m taking part in is building a Korean site for Ant Design, and I joined the testing team. We don’t write tests at work, so I haven’t had another opportunity to try it. This felt like a good chance. There are working developers and lots of job seekers, so we talk about development a lot. It seems to serve as a great community, too. I want to put my all into these five weeks.

Become a developer with good soft skills.

My idea of a good developer is a well-rounded one. Of course developers should be good at development. But when I think about someone I’d want to work with, I picture a colleague I can communicate with, rely on, and feel comfortable around. That’s why I think a good developer balances all of these qualities. Actually having them all is difficult. I used to think being good at coding was all that mattered, even with a bad personality, so I suspect my own soft skills need work. These days I’m learning a lot from the colleagues around me and trying to make those qualities my own. I want to be a developer people feel comfortable working with and want to work with.

A Next.js environment variable issue

We had to ship a hotfix this week. I think it was such a silly mistake. I used an environment variable without the NEXT_PUBLIC prefix in Next.js, which caused side effects. I regret not checking more carefully.

Let’s revisit environment variables in Next.js. https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables

Environment variables without NEXT_PUBLIC_ are available only in the Node.js environment. In other words, the browser can’t access them (the client runs in a different environment). To make a variable’s value accessible in the browser, Next.js can “inline” it into the JavaScript bundle sent to the client at build time, replacing every reference to process.env.[variable] with a hardcoded value.

That’s what the Next.js documentation explains. Let’s look a little deeper into how environment variables work.

Next.js is statically optimized at build time. Environment variables are generally evaluated and inserted during the build. For security reasons, they are accessible only on the server by default. Next.js splits code into multiple bundles to optimize performance. The JavaScript bundle sent to the client includes only the necessary code. So NEXT_PUBLIC variables are statically replaced to minimize bundle size. This is more efficient than fetching values dynamically at runtime. It also makes it clear to developers which variables are exposed to the client.

The sequence is:

  1. During the build, Next.js identifies environment variables with the NEXT_PUBLIC prefix.
  2. It inserts them inline into the client-side code.
  3. They become part of the client JavaScript bundle and are accessible in the browser.

Git revert and reset

Git revert moves the graph itself. Git reset transforms the code. So if you want to open a PR with reverted code after a revert, you need to revert the revert, because that code has already been merged.

Safari popups

https://stackoverflow.com/questions/44073069/why-is-my-popup-blocked-on-touch-but-not-click-using-pointerdown-listener

https://stackoverflow.com/questions/2587677/avoid-browser-popup-blockers/40283785#40283785

  • If JavaScript tries to open a popup automatically without user interaction, the browser may consider it suspicious and block it. It’s better to open popups as part of a clear user interaction than asynchronously in the background.
  • Popups fail to open inside asynchronous functions because of browsers’ popup blocking policies. Most browsers require popups to open through direct user interaction, such as clicking a button or link. Opening one inside an asynchronous function creates a time gap between the interaction and the popup, so the browser may consider it abnormal and block it.

Here’s an example of a popup being blocked in an asynchronous function.

const handleClick = async () => {
	await someAsyncTask(); // An asynchronous task (e.g., an API call or timer)
	const popup = window.open("about:blank", "_blank"); // The popup may be blocked
};

Solution

const handleClick = async () => {
	// Open the popup synchronously immediately after the user interaction
	const popup = window.open("about:blank", "_blank");
	// Perform the asynchronous task
	await someAsyncTask(); // E.g., an API call or timer

	// Set the popup's URL after the asynchronous task completes
	popup.location.href = "/new-url";
};

Other things…