DEV Community

Gerardo Enrique Arriaga Rendon
Gerardo Enrique Arriaga Rendon

Posted on

My First Time Contributing to Telescope

Our professor gave us an interesting challenge:

Ccontribute to several open source projects that you can find in GitHub for Hacktoberfest.
I will expect at least 4 successfully created Pull Requests (PR).
They do not have to be accepted, but you have to show that you put the effort and dedication; a genuine piece of work has to be shown.

One might consider this a really easy task, specially if one is used to contributing to open source. However, for students, that are still taking their program, this might be a huge thing, specially since they should contribute to real open source projects. In my case, I consider this a huge experience, and I am glad I had the opportunity to go through it.

The Contribution

I started by contributing to Telescope, a blog post aggregator.

The Issue

I began by finding existing issues, since it is faster than trying to find an issue myself. After some tribulations, I started to work on the issue Search page error.

The problem was a curious bug that would show an error page if you clicked to go to the search page while having the search bar filled with a query. You can view more details on the first comment in the issue thread.

I got some assessment from my classmate, Duc Bui Manh, as well as from my professor, David Humphrey. Really important assessment, since I did not know much about Telescope and its underlying architecture. They pointed me at the right direction, which was updating one of the dependencies, swr.

Upgrading SWR

Upgrading a dependency sounds easy, right? Well, it would be easy if it was being an upgrade across minor versions, but that wasn't the case. I had to upgrade SWR from version 0.5 to release 1.0, which of course brought some breaking changes.

Setting up Telescope for testing was not much trouble, since the documentation available was very straightforward, and I only had to update a dependency on the front-end, so no need to worry about setting the back-end (I did set up anyway, just to be sure that it was working fine).

I upgraded the dependency, and then started the project. The first roadblock was that the project couldn't even show the starting page!

I tried to read the documentation for SWR to understand what the issue was, but I couldn't figure it out. After asking in the Slack channel for Telescope about the issue, Duc answered to me. He mentioned that the issue was probably related to the importing. He was right. Since the function we used, useSWRInfinite was moved to another part of the SWR project, I had to fix the importing statements.

After doing that change, the starting page showed up, but now another issue showed up, or, I should say, it did not show up. I am talking about the posts that Telescope aggregates. For some reason, the posts wouldn't show up. I started to debug and read the code, and then I noticed that there is no request to get the posts being made. This helped me to narrow my search.

I had a major question in my head: why is there no fetching of the blog posts? After all, it was working before. Because this issue could only be caused by SWR's changes, I decided to read the source code of the dependency back when it was on its 0.5 release. I discovered that the fetcher function, the one in charge of making the requests, was defined by the SWR dependency.

This helped me to clear so many issues in my head. After I learned that there was no implicit fetcher function, I started to pass a default fetcher function to all uses of SWR hooks that did not pass any fetcher, since it meant they were using the default fetcher.

After applying the changes, everything was working fine, and the issue was also fixed! Thus, I created my PR to Telescope and waited.

The Pull Request

I managed to submit my PR, but it was not accepted without proper review, and I am glad it wasn't, since there was some misunderstanding to clear out.

Duc mentioned that the hooks from SWR declare the fetcher as optional, while I thought that the fetcher was required. David later commented that I could define a global context for SWR to grab a default definition of the fetcher.

Thus, the latest commit for my PR was on its tracks: I added the global context for the default fetcher and I removed the explicit arguments where unnecessary. After a while, both Duc and David approved my PR, thus successfully merging it with the master branch in Telescope!


While I could have finished this PR in less time if I hadn't researched about why the code was working before and then reading the source code of swr, I believe that I learned quite a lot about the usage of swr and its internal components.

I am very satisfied with how I went through this PR, because I learned about several things of the JavaScript/Front-end ecosystem, which I do not know anything about.

Discussion (0)