I thought online problems were tough enough, but it was the occasional online problem that killed me

For a few days did not write the article, today does not pull the code, talk about the point without much nutrition experience

First, the really difficult problem

As the front end that is closest to the user, every time there is a problem, of course, it is the first to bear the brunt of it. If there is a problem, it will just stop. Debugging or capturing packages, anyway, are their own problems to solve the problem, not their own problems, and it is convenient to shake the pot out. However, if the project happens to be highly complex, with long links and many related parties, and the problem is an occasional online problem, it is like checking the boulder on the track of a moving train without knowing where the boulder will appear, do you think it is hopeless

What do you do when you have a problem like this? Certainly not giving up

Second, how to respond

Try to find a recurrence path

Although it is an occasional problem, if the recurrence rate is high, it takes some experience and luck to try to find some intrinsic correlation among these recurrence phenomena, such as weak nets, fast repeat clicks, timeout operations, etc. If you are lucky enough to find the required path, congratulations, the problem has been downgraded from an occasional problem to a required problem Level. This time should how to do also need me to teach you!! ?

Analyze possible problems in the code and reverse the required path

The first step above, you can ask the test students to help operate, and you can focus on the analysis of your code, consider various scenarios, whether there will be loopholes, whether it will cause problems, and then reverse the must appear path. If some inverse derivation of the path just happens to reproduce the problem. Then, after you pat your thighs, move your fingers and you can enjoy your afternoon tea

Improving monitoring logs

No one in the whole project team can reproduce this problem, or even if the test student reproduces it by chance, there is no time for you to debug and capture the log. You won’t be able to analyze the code, so you’ll have to rely on the logging system. Print a log and upload it to the log system where you feel it is necessary. After all, with the scale of online users, even if the probability of this happening is only 1 in 1000, it is easy to gather some key information

After the version with the log has been sent for a while, it is time to analyze the log. Did an interface report an error? Does a native JS API not return? Or is some data type returned the day after tomorrow not as expected? Anyway, we can finally throw the pot out

Log id of a series full link

Said, in front of the whole system has high complexity, the link is very long, if you collect abnormal log, just didn’t receive the background of A message, when you are justified to find module A background schoolmates, he gave you A white after checked the log, you see you see, my message sent, should be there is something wrong with the other modules. And then you go to module B and module C, and you get the same answer, and you say who can you throw the pot to

Of course, this article is not for you to blame, after all, whose problems are all the problems of this project, as a project member, you should have the awareness of owner, no matter what the problem is, you should try to locate and solve

At this time, we not only need to have logs for each module, but also need to have a unique identifier that can connect the whole link. That is to say, at the beginning of the design, the front and background as well as each related party, to do a good job of the log system design of the whole link. That way, if something goes wrong, there’s a trace, and it’s easy to spot the problem

Third, summary

To solve the problem of occurrence, experience is crucial, which needs to be slowly accumulated, there is nothing to say. Then the most important thing is to design a good logging system, which requires the effort of the entire project team, and you need to be a facilitator

React and VUE are both state-oriented, data-driven programming