1. Clearly define the problem you’re investigating
Querying for ‘sequelize isn’t working’ will get you very different results than narrowing down the scope of your problem until you have one discrete gap in your understanding. Narrow down your question as much as possible.
2. Seek knowledge with just that goal in mind
There are so many interesting things to get distracted by. Ask yourself ruthlessly: is this helping to fill that specific gap in my knowledge? Is this helping me make progress beyond the point I got stuck?
3. Time Bound your investigations
Set a clear goal for how long you are willing to dedicate to this task. While your initial time constraint may not be realistic, knowing that you’re trying to figure this out in 2 minutes will prevent you from getting too distracted. Creating artificial time shortages is a great way to induce focus.
4. Investigate the interfaces, not the underlying functionality
Since you’re so tightly time bound, don’t dive deeply into how things work. Look only at the input and outputs. Source code is fun to read through, but this is not the time for that. Look only at the interfaces of what you’re dealing with, not what all the smart people have built in under the surface.
Those four points will prevent you from getting ratholed on any given project. But what about even higher level? What about keeping distraction out of your life more generally?
One ‘trick’ I’ve been using for a while was put very nicely by Elon Musk in his recent Ask Me Anything on reddit (a wonderfully tempting rathole itself).
“One bit of advice: it is important to view knowledge as sort of a semantic tree – make sure you understand the fundamental principles, ie the trunk and big branches, before you get into the leaves/details or there is nothing for them to hang on to.” -Elon Musk
In other words, focus on the 3-5 key areas in your life, and make sure that everything you do attaches to those. If you start adding all kinds of random knowledge, it’s interesting at the time, but there’s so much around that discrete piece of information you’re unaware of that you’ll quickly drift off into DistractionLand (like DisneyLand, but full of mostly the annoying rides).
My main trunks right now are coding, biking, and climbing. I used to get super distracted by all the interesting things in the world (there are so many interesting things! I’m a super curious person, and wanted to learn all of the things!). But I’ve found it so much easier on my brain recently to pare down all that random knowledge that didn’t tie to anything. Now I can focus on deepening my understanding in the areas of my life that I think are most important. Since all the knowledge ties together, not only is it easier on my brain, but I have a much richer understanding of what was said than if I didn’t have a main trunk to connect back to.
I hope this helps, both on a tactical level, and maybe as a thought-starter for how you focus your larger chunks of time.