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

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

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

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

מתוזמן נעוץ נעול הועבר תכנות
9 פוסטים 4 כותבים 45 צפיות 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 תגובה אחרונה
          3
          • ש ששא

            @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 תגובה אחרונה
            2
            • dovidD מנותק
              dovidD מנותק
              dovid
              ניהול
              כתב נערך לאחרונה על ידי
              #6

              @צדיק-תמים ספציפית פה try גדול יותר היה טוב יותר ודוק 🙂

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

                @צדיק-תמים ספציפית פה try גדול יותר היה טוב יותר ודוק 🙂

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

                @dovid הכי טוב היה בלי try בלבד חוץ מנקודתי בשורה שרוצים לטפל בשגיאות שלה בצורה שונה
                יש לספריה קאלבק מיוחד כדי לטפל בשגיאות לא צפויות בצורה מרוכזת במקום לפזר בקוד try catch

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

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

                  @dovid @צדיק-תמים
                  לכל מאן דבעי:
                  אני משתמש בide ואני מבין דבר או שניים במה שאני עושה.
                  קודם כל היה חשוב לי לעדכן בעקבות ההשמצות 😠

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

                  לא הבנתי מה יצא מכל הסיפור זה טוב try/catch? זה לא טוב? למה זה קרס?
                  הtry/catch הארוך הוא כי עשיתי שינוי על שינוי לטובת הלקוח. אז נשאר כזה ארוך, סתם להבין מה רע בזה?

                  תגובה 1 תגובה אחרונה
                  0
                  • צדיק תמיםצ צדיק תמים

                    @dovid הכי טוב היה בלי try בלבד חוץ מנקודתי בשורה שרוצים לטפל בשגיאות שלה בצורה שונה
                    יש לספריה קאלבק מיוחד כדי לטפל בשגיאות לא צפויות בצורה מרוכזת במקום לפזר בקוד try catch

                    E מחובר
                    E מחובר
                    eido
                    כתב נערך לאחרונה על ידי
                    #9

                    @צדיק-תמים אם אני מבין נכון, לא עושים בכאלו מקרים לא await ואין צורך בreturn, או שלא הבנתי נכון.

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


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

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

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