для каждого звонка, и это, вероятно, проблема.

ользовал события в nodejs для реализации моей логики. И «nextParams» - это событие, которое заставляет функцию «extractVideo» выполняться снова. Я знаю, что использовал рекурсивный цикл обработки событий. Я пытался использовать setTimeout (function, 0) и setTimeout (function, 1) в моем коде, но все еще появляется ошибка «Превышен максимальный размер стека вызовов», интересно, кто-нибудь знает, как решить эту проблему, я очень признателен !

    videoCrawler.prototype.extractVideo=function(queryStr){ 
       self.on("videoIdArray",function(){
            if(videoIdArray.length){
                self.getVideoInfo(videoIdArray.pop());
            }else{
                self.videomonitor.emit("nextParams");
            }
        });

        self.on("getVideoIdArray",function(videoidarray){
            if(!(videoidarray || videoidarray.length)){
                self.videomonitor.emit("nextParams");
            }
              videoIdArray=videoidarray;
              self.getVideoInfo(videoIdArray.pop());
        });

        self.on("save",function(videodetailinfo){
            if(!videodetailinfo){
                if(videoIdArray.length){
                    self.getVideoInfo(videoIdArray.pop());
                }else{
                    self.videomonitor.emit("nextParams");
                }
            }
            self.saveVideoInfo(videodetailinfo);
        });
        self.on("errorCapture",function(errInfo){             
            if(errInfo.message=="queryStr is not exits"){
                setTimeout(self.videomonitor.emit("nextParams"),1);
            }else if(errInfo.message=="videodetailsinfo is not exits"){
                self.getVideoInfo(videoIdArray.pop());
            }else if(errInfo.message=="videoId is empty"){
                self.getVideoInfo(videoIdArray.pop());
            }else if(errInfo.message=="save fails"){
                self.getVideoInfo(videoIdArray.pop());
            }
        });
        self.getVideoId(queryStr);  
    }

ниже приведены функции

    videoCrawler.prototype.getVideoId=function(queryStr){
      if(!queryStr) this.emit("errorCapture",errInfo);
       //dosomething
       this.emit("getVideoIdArray",videoArray); 
    }

      videoCrawler.prototype.getVideoInfo=function(videoId){
      if(!queryStr) this.emit("errorCapture",errInfo);
       //dosomething
      self.emit("save",videodetails);
      }

      videoCrawler.prototype.saveVideoInfo=function(videodetailsinfo){
       if(!queryStr) this.emit("errorCapture",errInfo);
        //dosomething
       self.emit("videoIdArray");
      }

Ответы на вопрос(1)

Ваш ответ на вопрос