إصدار Node.js 26.5.0 متاح الآن. إنه إصدار حالي (Current)، وليس فرع دعم طويل الأمد (LTS)، لذا فهو يمثل الطليعة لما يمكن للمنصة القيام به. هذا التمييز مهم؛ فلا ينبغي عليك استبداله بشكل أعمى في بيئة إنتاج تتوقع استقراراً لمدة ثمانية عشر شهراً. لكن هذه الإصدارات الصغيرة والسريعة هي المكان الذي تراقب فيه المستقبل وهو يتشكل، فهي توضح أي واجهات برمجة التطبيقات (APIs) يقوم المطورون بتحسينها وإلى أين يتجه وقت التشغيل (runtime) لاحقاً. في الإصدار 26.5.0، يتركز العمل الرئيسي في واجهة برمجة تطبيقات Web Streams API، مع زوج من الإصلاحات المستهدفة التي تقرب Node من مستوى التوافق مع المتصفحات. كما يقوم الإصدار أيضاً بتنظيف بعض العيوب في طبقات نظام الملفات ومعالجة الروابط (URL).

ما هو دور Web Streams في Node.js؟

إذا كنت قد كتبت كوداً يعتمد على التدفق (streaming) في Node لفترة من الوقت، فأنت تعلم أن وحدة stream المدمجة لها طابعها الخاص. لقد كانت Readable و Writable و Transform و Duplex هي العمود الفقري للنظام لسنوات. إنها قوية، لكنها ليست هي نفسها التدفقات (streams) التي تجدها في المتصفح. عندما تحاول مشاركة المنطق البرمجي بين "service worker" في الواجهة الأمامية ومعالج مسار (route handler) في الواجهة الخلفية، يصبح هذا الفارق عائقاً. ينتهي بك الأمر بإعادة كتابة المحولات (adapters)، أو نسخ البيانات إلى أشكال غير مألوفة، أو ببساطة تجنب الكود المشترك تماماً.

توجد واجهة برمجة تطبيقات Web Streams لسد هذه الفجوة. إنها المعيار نفسه الذي يدعم معالجة جسم الطلب (body handling) في fetch داخل المتصفح. ومن خلال جلبها إلى Node، يتيح لك المشروع كتابة منطق التدفق مرة واحدة وتشغيله في أي من البيئتين. تتعامل واجهة برمجة التطبيقات مع كائنات ReadableStream و WritableStream و TransformStream التي تمرر أجزاء البيانات عبر واجهة موحدة. لا يعيد الإصدار 26.5.0 كتابة هذه الواجهة، ولكنه يعالج أمرين مهمين.

إصلاح releaseLock وتنظيف قراء BYOB

أحد التغييرات الملموسة في هذا الإصدار هو إصلاح طريقة releaseLock في WritableStreamDefaultWriter. في نموذج Web Streams، يمنع قفل الكاتب (writer lock) المستهلكين المتعددين من التداخل مع نفس التدفق في وقت واحد. عندما تستدعي releaseLock()، فإنك تشير إلى أن الكاتب قد انتهى وأن التدفق الأساسي متاح للعملية التالية. يمكن أن يؤدي التنفيذ الخاطئ هنا إلى ترك التدفق في حالة معلقة، حيث يعتقد أنه لا يزال مملوكاً رغم اختفاء الكاتب. في خادم مزدحم يقوم بتحليل عمليات الرفع أو تمرير البيانات إلى التخزين، يمكن لهذا النوع من الأقفال العالقة أن يعطل خط الأنابيب (pipeline) أو يتسبب في أخطاء يصعب تتبع مصدرها. يجعل الإصلاح في 26.5.0 عملية التسليم متوقعة مرة أخرى.

التغيير الثاني في Web Streams يحسن كيفية عمل ReadableStream و TransformStream مع قراء BYOB. يرمز BYOB إلى "Bring Your Own Buffer" (أحضر مخزنك المؤقت الخاص بك). بدلاً من قيام التدفق بتخصيص جزء جديد من الذاكرة في كل مرة يقدم فيها بيانات، فإنك تمنحه مخزناً مؤقتاً (buffer) قمت بتخصيصه مسبقاً. يقوم التدفق بملء هذا المخزن، ثم تعالج أنت البايتات، وبعد ذلك تعيد نفس المخزن لإعادة استخدامه. إنه اختلاف ميكانيكي صغير ينتج عنه نتائج هائلة عندما تقوم بنقل كميات كبيرة من البيانات.

لقد كان Node يدعم BYOB لفترة من الوقت، ولكن كانت هناك حالات حافة (edge cases) في ReadableStream و TransformStream قد تسلك سلوكاً خاطئاً عند إرفاق قارئ BYOB. تهم التفاصيل الدقيقة للإصلاح أقل مما تهم النتيجة العملية: أصبحت التدفقات التي تستخدم مخازن مؤقتة صريحة أكثر موثوقية عبر مرحلتي القراءة والتحويل. إذا كنت قد تجنبت قراء BYOB بسبب أخطاء غريبة أثناء أحداث الضغط العكسي (backpressure)، فإن هذا الإصدار يزيل سبباً آخر للابتعاد عنها.

أين يظهر BYOB فعلياً

من السهل التحدث عن إعادة استخدام المخزن المؤقت بشكل مجرد، ولكن من المفيد التفكير في الأماكن التي يبرز فيها أثره.

تخيل أنك تكتب خدمة تقبل عمليات رفع بيانات القياس عن بُعد (telemetry). قد تكون عمليات الرفع هذه سجلات مضغوطة أو بيانات مستشعرات خام، ويبلغ حجم كل منها عدة مئات من الميجابايت. إذا كان التدفق يخصص Buffer جديد في Node لكل جزء من البيانات، فإن جامع المهملات (garbage collector) سيعمل فوق طاقته وسترتفع قفزات الذاكرة بسرعة. باستخدام قارئ BYOB، يمكنك تخصيص مجموعة متواضعة من المخازن المؤقتة عند بدء التشغيل. يقوم التدفق بملئها، ويقوم المحلل الخاص بك بتفريغها، ثم تعود للدورة مرة أخرى. تظل الذاكرة مستقرة. ينطبق النمط نفسه عندما تقوم بتوجيه حركة مرور الشبكة (proxying) بين مقبسين (sockets) أو تحليل ملفات CSV كبيرة سطراً بسطر دون تحميل الملف بأكمله في ذاكرة الوصول العشوائي (RAM).

Transform streams are equally important here. A TransformStream sits in the middle of a pipeline, perhaps decompressing a gzip stream or encrypting chunks on the fly. If the transform step mishandles BYOB buffers, you can see corrupted output, dropped chunks, or stalls under load. The 26.5.0 fixes address exactly those kinds of pipeline hiccups, which is why anyone running high-throughput I/O should pay attention.

The Quiet Wins: File System and Error Clarity

Not everything in 26.5.0 is about streaming. The release also fixes behavior in fs.rm and fs.rmSync when the recursive option is set to false. Previously, passing recursive: false alongside a directory path could produce unexpected results during cleanup. The method might act in ways that did not match the explicit intent of the caller, deleting more than expected or failing in inconsistent ways depending on the platform. Cleaning up files is the sort of operation that should be boring and predictable. Boring is good. This fix restores that predictability, so your temporary directory cleanup scripts or deployment teardown logic behave exactly as the code suggests.

There is also a quality-of-life improvement in how URL.canParse reports failure. The method checks whether a string is a valid URL without throwing on malformed input. In 26.5.0, it now carries better Error.cause information when something goes wrong. Rather than swallowing the original reason, the error object preserves a causal chain. That means when a URL parse fails deep inside a validation helper, the stack you log tells you whether the issue was a bad protocol, a missing hostname, or some other structural problem. You spend less time sprinkling manual debug logs across every call site.

Should You Upgrade?

The answer depends on what you are running.

If your production workloads sit on an LTS version such as the v20.x line, stay there. These fixes will eventually backport or arrive in the next active LTS. Stability and predictable support timelines outweigh the benefit of a slightly smoother stream lock or clearer URL error on a server that is already working.

If you are building a new service, prototyping a real-time data pipeline, or actively using the Web Streams API for performance-critical I/O, 26.5.0 is worth the jump. The incremental alignment between Node streams and browser Web Streams is not just a compatibility win. It is a bet on a more unified JavaScript runtime where the same data-pushing logic can travel between server and client without translation layers. That cuts down on cognitive load and reduces the surface area for bugs when your team ships code to both environments.

This release is small, but the direction is clear. Node is continuing to invest in standards-based APIs that work everywhere JavaScript runs. The Web Streams improvements are not headline features, but they smooth out a path that has been rocky for years. Grab 26.5.0 if you live on the Current line, and watch for these fixes to land in your LTS world when the time is right.

Source: Dev.to – Node.js 26.5.0: What's New for Web Streams and Error Handling

Join the discussion and keep learning with the GyaanSetu community on Telegram.