🗣️ Story
Once, we discovered a bug in the core of
Vue.js.
It all started because we wanted to
justify the text on
grammy.dev. This means that all lines have the same width, and words are broken up and squeezed and stretched to fit. Justified text is most often found in books and newspapers. However, it comes with a bunch of problems for technical documentation.
We sometimes have very long inline code snippets such as an example file identifier at
https://grammy.dev/guide/files#how-files-work-for-telegram-bots. We also sometimes have long links like at
https://grammy.dev/plugins/auto-retry#plugin-summary. Browsers are quite good at breaking up words in natural language (at least in English), but they cannot deal with elements like inline code snippets or URLs. And even if they did: it would be very strange to see a code snippet that goes like
await bot.api.send-
Message(chat_id, "hi");
because what is that hyphen in send-Message doing there???
Fortunately, there are tags in HTML.
They indicate line break opportunities. Browsers are allowed to break text at these positions without inserting any hyphen. All we needed to do was to inject lots of tags at the right places into inline code snippets and URLs during the build process. This can be done with
a bunch of incomprehensible regular expressions.
However, these invisible characters are apparently not very commonly used. At least, Vue.js had its problems with them. When
grammy.dev was visited,
the client-side hydration of Vue.js would sometimes accidentally duplicate parts of some paragraphs on duplicate parts of some paragraphs on
grammy.dev.
Firstly, we reported this in
a discussion on GitHub. At that point, we still believed it could be our strange regex that broke things.
Secondly, we were able to
narrow it down even further to a very primitive website (without regex) that still had the same bug.
Thirdly, someone who knows a lot more about Vue.js than us opened
a proper bug report based on our findings on the Vue.js core repo.
Lastly, Vue.js founder
Evan You personally fixed the bug in
this pull request which resulted in
this commit.
The Vue.js hydration tests covering our edge case contain bits of our reproduction example to this very day.
This story is a good example of open-source projects empowering each other. We use the entire frontend stack for free for our docs, and therefore we give back to the community behind it. Next time you use an open-source project for free, take a second to think about the thousands of stories like ours. They make possible what we all sometimes take for granted.
And now, get back to coding. 🤖