דילוג לתוכן
  • דף הבית
  • קטגוריות
  • פוסטים אחרונים
  • משתמשים
  • חיפוש
  • חוקי הפורום
כיווץ
תחומים

תחומים - פורום חרדי מקצועי

💡 רוצה לזכור קריאת שמע בזמן? לחץ כאן!
  1. דף הבית
  2. תכנות
  3. לוגי שגיאה בnodejs וyemotrouter מה הגורם לקריסה?

לוגי שגיאה בnodejs וyemotrouter מה הגורם לקריסה?

מתוזמן נעוץ נעול הועבר תכנות
5 פוסטים 4 כותבים 27 צפיות 3 עוקבים
  • מהישן לחדש
  • מהחדש לישן
  • הכי הרבה הצבעות
תגובה
  • תגובה כנושא
התחברו כדי לפרסם תגובה
נושא זה נמחק. רק משתמשים עם הרשאות מתאימות יוכלו לצפות בו.
  • E מנותק
    E מנותק
    eido
    כתב נערך לאחרונה על ידי eido
    #1

    יש כאן כמה לוגים של שגיאה, רק אחד מהם גרם לקריסה ממש, אשמח לדעת מה גרם לקריסה, ומה הוא שונה מהשאר. לכאורה הם בערך אותם שגיאות.

    [541eba6e6682e37cee0ae3e53f2d794defc28d29]: 💥 Uncaught error. applying uncaughtErrorHandler (node:internal/errors:405:5)
    Uncaught error in / from 0548497730. error stack: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at new NodeError (node:internal/errors:405:5)
    at ServerResponse.setHeader (node:_http_outgoing:655:11)
    at ServerResponse.header (/home/node.stamandsefer.co.il/public_html/node_modules/express/lib/response.js:684:10)
    at ServerResponse.send (/home/node.stamandsefer.co.il/public_html/node_modules/express/lib/response.js:161:12)
    at Call.send (file:///home/node.stamandsefer.co.il/public_html/node_modules/yemot-router2/lib/call.js:264:18)
    at sendResp (file:///home/node.stamandsefer.co.il/public_html/node_modules/yemot-router2/lib/call.js:170:18)
    at Call.read (file:///home/node.stamandsefer.co.il/public_html/node_modules/yemot-router2/lib/call.js:179:15)
    at choosestreet (file:///home/node.stamandsefer.co.il/public_html/src/utils/utils_func.js:141:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async callHandler (file:///home/node.stamandsefer.co.il/public_html/src/controllers/addAdController.js:60:22)
    [541eba6e6682e37cee0ae3e53f2d794defc28d29]: Cannot send id_list_message after sending response (probably done from uncaughtErrorHandler due to error in asynchronous code

    [a7d099fc6c8dea530efaabba6c1b4ceb5476adb8]: 💥 Uncaught error. applying uncaughtErrorHandler (node:internal/errors:405:5)
    Uncaught error in / from 0548497730. error stack: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at new NodeError (node:internal/errors:405:5)
    at ServerResponse.setHeader (node:_http_outgoing:655:11)
    at ServerResponse.header (/home/node.stamandsefer.co.il/public_html/node_modules/express/lib/response.js:684:10)
    at ServerResponse.send (/home/node.stamandsefer.co.il/public_html/node_modules/express/lib/response.js:161:12)
    at Call.send (file:///home/node.stamandsefer.co.il/public_html/node_modules/yemot-router2/lib/call.js:264:18)
    at sendResp (file:///home/node.stamandsefer.co.il/public_html/node_modules/yemot-router2/lib/call.js:170:18)
    at Call.read (file:///home/node.stamandsefer.co.il/public_html/node_modules/yemot-router2/lib/call.js:179:15)
    at choosestreet (file:///home/node.stamandsefer.co.il/public_html/src/utils/utils_func.js:141:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async callHandler (file:///home/node.stamandsefer.co.il/public_html/src/controllers/addAdController.js:60:22)
    [a7d099fc6c8dea530efaabba6c1b4ceb5476adb8]: Cannot send id_list_message after sending response (probably done from uncaughtErrorHandler due to error in asynchronous code

    [b142a8637dd7dced030099e0f6655a63da484e0b]: 💥 Uncaught error. applying uncaughtErrorHandler (node:internal/errors:405:5)
    Uncaught error in / from 0583297790. error stack: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at new NodeError (node:internal/errors:405:5)
    at ServerResponse.setHeader (node:_http_outgoing:655:11)
    at ServerResponse.header (/home/node.stamandsefer.co.il/public_html/node_modules/express/lib/response.js:684:10)
    at ServerResponse.send (/home/node.stamandsefer.co.il/public_html/node_modules/express/lib/response.js:161:12)
    at Call.send (file:///home/node.stamandsefer.co.il/public_html/node_modules/yemot-router2/lib/call.js:264:18)
    at sendResp (file:///home/node.stamandsefer.co.il/public_html/node_modules/yemot-router2/lib/call.js:170:18)
    at Call.read (file:///home/node.stamandsefer.co.il/public_html/node_modules/yemot-router2/lib/call.js:179:15)
    at choosestreet (file:///home/node.stamandsefer.co.il/public_html/src/utils/utils_func.js:141:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async callHandler (file:///home/node.stamandsefer.co.il/public_html/src/controllers/addAdController.js:60:22)
    [b142a8637dd7dced030099e0f6655a63da484e0b]: Cannot send id_list_message after sending response (probably done from uncaughtErrorHandler due to error in asynchronous code after returning response)
    Node starting...
    app.js running on port 3000

    export async function choosestreet(call, city) {
            let menuStreet = "", digitsStreet=[], street;
    
        let okStreet = "0";
        while(okStreet!="1")
        {
            let ans = await call.read([{ type: 'file', data: "/ivr_records/רחוב1" }], "record");
            console.log(ans);
        try{
            const keywords = JSON.stringify(streets[city]);
    street = await reco(call, ans,keywords, city);
    if (street==null) {continue;}
    }
        catch (error) {
         console.error("Error:", error);
         call.id_list_message([{ type: 'text', data: "אירעה שגיאה" }]);
    }
    {
        // מבקש אישור
        okStreet = await call.read([{ type: 'file' , data: `/ivr_records/${street}` },{ type: 'file' , data: "/ivr_records/אישור2" }], 'tap', {
                sec_wait: 2,
                min_digits: 1,
            typing_playback_mode: "No",
            digits_allowed: [1,2, "*0"]
        });
        if (okStreet=="1")
        {return street;}
        else if (okStreet == "*0") {call.go_to_folder(mainextPath);}
        }
    
    }
    
    async function reco(call, ans, keywords,city) {
        try{
     const { stdout, stderr } = await execFileAsync("python3", [
             "/recognizeNew.py",
            ans,keywords]);   
            const matches = JSON.parse(stdout);
    
    console.log(matches);
    if (stderr) {
        console.error("Python stderr:", stderr);
    }
    if (matches.length==0)
    {
              const { stdout, stderr } = await execFileAsync("python3", [
             "recognize.py",
            ans,keywords]);
            if (stderr) {
        console.error("Python stderr:", stderr);
    }
             let recognizedText = stdout.trim(); // הסר רווחים ושורות מיותרות
          
           if(streets[city].includes(recognizedText))
           {
            return recognizedText;
           }
           else
           {call.id_list_message([/*{type: 'text', data: "לא זיהינו את הרחוב שהקלטת"}*/{ type: 'file', data: "/ivr_records/שגיאה זיהוי" }],{prependToNextAction: true});}
    }
    else 
    if (matches[0].score == 100)
    {return matches[0].name;}
    else
    {
        let msgmatches = [], digitsmatches=[];
        for (let i = 0; i < matches.length; i++) {
    
            msgmatches.push({ type: 'file', data: `/ivr_records/${matches[i].name}` });
            msgmatches.push({ type: 'file', data: `/ivr_records/הקש` });
            msgmatches.push(...Object.values(numberToHebrewWords(i+1)));
            digitsmatches.push((i + 1).toString());
        }
        digitsmatches.push("*0");
    
        let street;
        for(let i = 0; i<3; i++)
        {
    
    
        street = await call.read(msgmatches, 'tap', {
            max_digits: 2,
                sec_wait: 2,
                min_digits: 1,
                digits_allowed: digitsmatches,
            typing_playback_mode: "No"
        });
    
        if (street == "*0") {call.go_to_folder(mainextPath);}
    
    
            if (!digitsmatches.includes(street)) {
            continue; // אם הקיש מספר לא חוקי – חוזר על הלולאה
        }
    
        const index = Number(street) - 1;
        if (index >= matches.length) {
            continue; // אם הקיש מספר לא חוקי – חוזר על הלולאה
        }
        street = matches[index].name;
        return street;
    }
    call.hangup();
    
    }
        }
        catch (error) {
         console.error("Error:", error);
         call.id_list_message([{ type: 'text', data: "אירעה שגיאה" }]);
    }
    }
    
    ש תגובה 1 תגובה אחרונה
    0
    • E eido

      יש כאן כמה לוגים של שגיאה, רק אחד מהם גרם לקריסה ממש, אשמח לדעת מה גרם לקריסה, ומה הוא שונה מהשאר. לכאורה הם בערך אותם שגיאות.

      [541eba6e6682e37cee0ae3e53f2d794defc28d29]: 💥 Uncaught error. applying uncaughtErrorHandler (node:internal/errors:405:5)
      Uncaught error in / from 0548497730. error stack: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
      at new NodeError (node:internal/errors:405:5)
      at ServerResponse.setHeader (node:_http_outgoing:655:11)
      at ServerResponse.header (/home/node.stamandsefer.co.il/public_html/node_modules/express/lib/response.js:684:10)
      at ServerResponse.send (/home/node.stamandsefer.co.il/public_html/node_modules/express/lib/response.js:161:12)
      at Call.send (file:///home/node.stamandsefer.co.il/public_html/node_modules/yemot-router2/lib/call.js:264:18)
      at sendResp (file:///home/node.stamandsefer.co.il/public_html/node_modules/yemot-router2/lib/call.js:170:18)
      at Call.read (file:///home/node.stamandsefer.co.il/public_html/node_modules/yemot-router2/lib/call.js:179:15)
      at choosestreet (file:///home/node.stamandsefer.co.il/public_html/src/utils/utils_func.js:141:30)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async callHandler (file:///home/node.stamandsefer.co.il/public_html/src/controllers/addAdController.js:60:22)
      [541eba6e6682e37cee0ae3e53f2d794defc28d29]: Cannot send id_list_message after sending response (probably done from uncaughtErrorHandler due to error in asynchronous code

      [a7d099fc6c8dea530efaabba6c1b4ceb5476adb8]: 💥 Uncaught error. applying uncaughtErrorHandler (node:internal/errors:405:5)
      Uncaught error in / from 0548497730. error stack: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
      at new NodeError (node:internal/errors:405:5)
      at ServerResponse.setHeader (node:_http_outgoing:655:11)
      at ServerResponse.header (/home/node.stamandsefer.co.il/public_html/node_modules/express/lib/response.js:684:10)
      at ServerResponse.send (/home/node.stamandsefer.co.il/public_html/node_modules/express/lib/response.js:161:12)
      at Call.send (file:///home/node.stamandsefer.co.il/public_html/node_modules/yemot-router2/lib/call.js:264:18)
      at sendResp (file:///home/node.stamandsefer.co.il/public_html/node_modules/yemot-router2/lib/call.js:170:18)
      at Call.read (file:///home/node.stamandsefer.co.il/public_html/node_modules/yemot-router2/lib/call.js:179:15)
      at choosestreet (file:///home/node.stamandsefer.co.il/public_html/src/utils/utils_func.js:141:30)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async callHandler (file:///home/node.stamandsefer.co.il/public_html/src/controllers/addAdController.js:60:22)
      [a7d099fc6c8dea530efaabba6c1b4ceb5476adb8]: Cannot send id_list_message after sending response (probably done from uncaughtErrorHandler due to error in asynchronous code

      [b142a8637dd7dced030099e0f6655a63da484e0b]: 💥 Uncaught error. applying uncaughtErrorHandler (node:internal/errors:405:5)
      Uncaught error in / from 0583297790. error stack: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
      at new NodeError (node:internal/errors:405:5)
      at ServerResponse.setHeader (node:_http_outgoing:655:11)
      at ServerResponse.header (/home/node.stamandsefer.co.il/public_html/node_modules/express/lib/response.js:684:10)
      at ServerResponse.send (/home/node.stamandsefer.co.il/public_html/node_modules/express/lib/response.js:161:12)
      at Call.send (file:///home/node.stamandsefer.co.il/public_html/node_modules/yemot-router2/lib/call.js:264:18)
      at sendResp (file:///home/node.stamandsefer.co.il/public_html/node_modules/yemot-router2/lib/call.js:170:18)
      at Call.read (file:///home/node.stamandsefer.co.il/public_html/node_modules/yemot-router2/lib/call.js:179:15)
      at choosestreet (file:///home/node.stamandsefer.co.il/public_html/src/utils/utils_func.js:141:30)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async callHandler (file:///home/node.stamandsefer.co.il/public_html/src/controllers/addAdController.js:60:22)
      [b142a8637dd7dced030099e0f6655a63da484e0b]: Cannot send id_list_message after sending response (probably done from uncaughtErrorHandler due to error in asynchronous code after returning response)
      Node starting...
      app.js running on port 3000

      export async function choosestreet(call, city) {
              let menuStreet = "", digitsStreet=[], street;
      
          let okStreet = "0";
          while(okStreet!="1")
          {
              let ans = await call.read([{ type: 'file', data: "/ivr_records/רחוב1" }], "record");
              console.log(ans);
          try{
              const keywords = JSON.stringify(streets[city]);
      street = await reco(call, ans,keywords, city);
      if (street==null) {continue;}
      }
          catch (error) {
           console.error("Error:", error);
           call.id_list_message([{ type: 'text', data: "אירעה שגיאה" }]);
      }
      {
          // מבקש אישור
          okStreet = await call.read([{ type: 'file' , data: `/ivr_records/${street}` },{ type: 'file' , data: "/ivr_records/אישור2" }], 'tap', {
                  sec_wait: 2,
                  min_digits: 1,
              typing_playback_mode: "No",
              digits_allowed: [1,2, "*0"]
          });
          if (okStreet=="1")
          {return street;}
          else if (okStreet == "*0") {call.go_to_folder(mainextPath);}
          }
      
      }
      
      async function reco(call, ans, keywords,city) {
          try{
       const { stdout, stderr } = await execFileAsync("python3", [
               "/recognizeNew.py",
              ans,keywords]);   
              const matches = JSON.parse(stdout);
      
      console.log(matches);
      if (stderr) {
          console.error("Python stderr:", stderr);
      }
      if (matches.length==0)
      {
                const { stdout, stderr } = await execFileAsync("python3", [
               "recognize.py",
              ans,keywords]);
              if (stderr) {
          console.error("Python stderr:", stderr);
      }
               let recognizedText = stdout.trim(); // הסר רווחים ושורות מיותרות
            
             if(streets[city].includes(recognizedText))
             {
              return recognizedText;
             }
             else
             {call.id_list_message([/*{type: 'text', data: "לא זיהינו את הרחוב שהקלטת"}*/{ type: 'file', data: "/ivr_records/שגיאה זיהוי" }],{prependToNextAction: true});}
      }
      else 
      if (matches[0].score == 100)
      {return matches[0].name;}
      else
      {
          let msgmatches = [], digitsmatches=[];
          for (let i = 0; i < matches.length; i++) {
      
              msgmatches.push({ type: 'file', data: `/ivr_records/${matches[i].name}` });
              msgmatches.push({ type: 'file', data: `/ivr_records/הקש` });
              msgmatches.push(...Object.values(numberToHebrewWords(i+1)));
              digitsmatches.push((i + 1).toString());
          }
          digitsmatches.push("*0");
      
          let street;
          for(let i = 0; i<3; i++)
          {
      
      
          street = await call.read(msgmatches, 'tap', {
              max_digits: 2,
                  sec_wait: 2,
                  min_digits: 1,
                  digits_allowed: digitsmatches,
              typing_playback_mode: "No"
          });
      
          if (street == "*0") {call.go_to_folder(mainextPath);}
      
      
              if (!digitsmatches.includes(street)) {
              continue; // אם הקיש מספר לא חוקי – חוזר על הלולאה
          }
      
          const index = Number(street) - 1;
          if (index >= matches.length) {
              continue; // אם הקיש מספר לא חוקי – חוזר על הלולאה
          }
          street = matches[index].name;
          return street;
      }
      call.hangup();
      
      }
          }
          catch (error) {
           console.error("Error:", error);
           call.id_list_message([{ type: 'text', data: "אירעה שגיאה" }]);
      }
      }
      
      ש מחובר
      ש מחובר
      ששא
      כתב נערך לאחרונה על ידי
      #2

      @eido כי יש כמה פעמים שאתה מחזיר משהו אבל אתה לא עוצר את הקוד, כך שהקוד ממשיך לרוץ ומחזיר כמה דברים ביחד, וזה מה שגורם לשגיאות כאלה

      צדיק תמיםצ תגובה 1 תגובה אחרונה
      1
      • E מנותק
        E מנותק
        eido
        כתב נערך לאחרונה על ידי
        #3

        הפקודה הזו call.id_list_message( אמורה לעצור את הקוד, אין סיבה לעצור אותו בנפרד... ככה אני מבין את זה.

        תגובה 1 תגובה אחרונה
        0
        • dovidD מחובר
          dovidD מחובר
          dovid
          ניהול
          כתב נערך לאחרונה על ידי dovid
          #4

          @eido יש רק שלוש דרכים לעצור קוד שרץ באמצע פונקציה בלי משפטי בקרה (if/for/break וכדומה):
          return
          throw
          await.
          בפונקציה choosestreet אתה קורא לid_list_message בתוך לולאה ובלי await.
          מהקוד הזה שלא מסודר מבחינת ההזחות יחד עם העובדה שיש שמה סוגריים מסולסלות מיותרות, אני לומד שאתה עובד קשה לכתוב קוד בלי IDE או ידע בסיסי בעניין. כדאי לך להשלים את החסרים האלה, זה יוריד ממך הרבה הרבה טרחה ותלמד הרבה יותר מהר להבין את הקוד.

          • מנטור אישי בתכנות והמסתעף – להתקדם לשלב הבא!
          • בכל נושא אפשר ליצור קשר dovid@tchumim.com
          תגובה 1 תגובה אחרונה
          1
          • ש ששא

            @eido כי יש כמה פעמים שאתה מחזיר משהו אבל אתה לא עוצר את הקוד, כך שהקוד ממשיך לרוץ ומחזיר כמה דברים ביחד, וזה מה שגורם לשגיאות כאלה

            צדיק תמיםצ מנותק
            צדיק תמיםצ מנותק
            צדיק תמים
            כתב נערך לאחרונה על ידי צדיק תמים
            #5

            @ששא כתב בלוגי שגיאה בnodejs וyemotrouter מה הגורם לקריסה?:

            @eido כי יש כמה פעמים שאתה מחזיר משהו אבל אתה לא עוצר את הקוד, כך שהקוד ממשיך לרוץ ומחזיר כמה דברים ביחד, וזה מה שגורם לשגיאות כאלה

            אדייק, בעיקרון הספריה עצמה מונעת מקרים כאלה על ידי זריקת שגיאה מלאכותית של ExitError אחרי פעולות שמחזירות למשתמש סטרינג שאמור להוציא אותו מהשלוחה

            CleanShot 2025-12-31 at 14.21.24@2x.png

            הבעיה היא ש @eido עושה try catch ענקיים בלי סיבה, וגם לא בודק את השגיאה

            Don’t comment bad code — rewrite it." — Brian W. Kernighan and P. J. Plaugher"
            טיפים

            תגובה 1 תגובה אחרונה
            1
            תגובה
            • תגובה כנושא
            התחברו כדי לפרסם תגובה
            • מהישן לחדש
            • מהחדש לישן
            • הכי הרבה הצבעות


            בא תתחבר לדף היומי!
            • התחברות

            • אין לך חשבון עדיין? הרשמה

            • התחברו או הירשמו כדי לחפש.
            • פוסט ראשון
              פוסט אחרון
            0
            • דף הבית
            • קטגוריות
            • פוסטים אחרונים
            • משתמשים
            • חיפוש
            • חוקי הפורום