Yassine Belkaid’s Post

🤯 𝗢𝗻𝗲 𝗼𝗳 𝘁𝗵𝗲 𝘄𝗲𝗶𝗿𝗱𝗲𝘀𝘁 (𝗮𝗻𝗱 𝘀𝗺𝗮𝗿𝘁𝗲𝘀𝘁) 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗽𝗮𝘁𝘁𝗲𝗿𝗻𝘀 𝗜'𝘃𝗲 𝘀𝗲𝗲𝗻: 👉 𝗨𝘀𝗶𝗻𝗴 𝗮 𝗽𝗿𝗼𝗺𝗶𝘀𝗲 𝘁𝗵𝗮𝘁 𝗡𝗘𝗩𝗘𝗥 𝗿𝗲𝘀𝗼𝗹𝘃𝗲𝘀... 𝗼𝗻 𝗽𝘂𝗿𝗽𝗼𝘀𝗲. 𝑎𝑤𝑎𝑖𝑡 𝑛𝑒𝑤 𝑃𝑟𝑜𝑚𝑖𝑠𝑒(() => {}); Yes, this is valid. And it's used in production. 🧠 𝗪𝗵𝗮𝘁 𝗶𝘁 𝗱𝗼𝗲𝘀 🔹 Execution stops at that line 🔹 No error 🔹 No exception 🔹 No special control flow 👉 The function just... never continues. ⚠️ 𝗪𝗵𝘆 𝗻𝗼𝘁 𝗷𝘂𝘀𝘁 𝘁𝗵𝗿𝗼𝘄 𝗮𝗻 𝗲𝗿𝗿𝗼𝗿? Because: 🔹 𝑡𝑟𝑦/𝑐𝑎𝑡𝑐ℎ can swallow it 🔹 Your control flow breaks silently 🧩 𝗪𝗵𝘆 𝘁𝗵𝗶𝘀 𝗶𝘀 𝗽𝗼𝘄𝗲𝗿𝗳𝘂𝗹 This pattern enables: 🔹 Interrupting async functions safely 🔹 Building resumable workflows 🔹 Controlling execution without changing user code 🚀 𝗥𝗲𝗮𝗹-𝘄𝗼𝗿𝗹𝗱 𝘂𝘀𝗲 𝗰𝗮𝘀𝗲: Serverless workflows that: 🔹 Run part of a function 🔹 Save progress 🔹 Resume later All while developers write plain 𝑎𝑠𝑦𝑛𝑐/𝑎𝑤𝑎𝑖𝑡. 🧠 𝗧𝗵𝗲 𝗱𝗲𝗲𝗽𝗲𝗿 𝗶𝗻𝘀𝗶𝗴𝗵𝘁: JavaScript doesn't let you cancel promises... 👉 But it DOES let you stop execution by never resolving them. ⚡ This is the kind of trick that turns: "async code" → into 𝒐𝒓𝒄𝒉𝒆𝒔𝒕𝒓𝒂𝒕𝒆𝒅 𝒔𝒚𝒔𝒕𝒆𝒎𝒔 🔗 Source: https://lnkd.in/d5M-Keeb #JavaScript #AsyncProgramming #WebDevelopment #AdvancedJS

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories