<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ibrahim Hafez</title>
    <description>The latest articles on DEV Community by Ibrahim Hafez (@ibrahimhafez1).</description>
    <link>https://dev.to/ibrahimhafez1</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4275048%2F22689e76-7ef2-43a4-8d64-584f3007660a.png</url>
      <title>DEV Community: Ibrahim Hafez</title>
      <link>https://dev.to/ibrahimhafez1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ibrahimhafez1"/>
    <language>en</language>
    <item>
      <title>When an ORM query slows down after the SQL returns</title>
      <dc:creator>Ibrahim Hafez</dc:creator>
      <pubDate>Tue, 01 Dec 2026 07:38:59 +0000</pubDate>
      <link>https://dev.to/ibrahimhafez1/when-an-orm-query-slows-down-after-the-sql-returns-12k5</link>
      <guid>https://dev.to/ibrahimhafez1/when-an-orm-query-slows-down-after-the-sql-returns-12k5</guid>
      <description>&lt;p&gt;Imagine loading 3,000 authors with one book each. Once the database returns the rows, how much work should it take to put each book on its author? In a TypeORM reproduction using SQL.js and &lt;code&gt;relationLoadStrategy: "query"&lt;/code&gt;, going from 1,500 to 3,000 authors pushed the measured load time from 712 ms to 2,607 ms. Each author still had exactly one book. &lt;a href="https://github.com/typeorm/typeorm/issues/13112" rel="noopener noreferrer"&gt;Benchmark and query&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first clue was an &lt;code&gt;array-repeated-find&lt;/code&gt; finding from Loadwise. For each entity, TypeORM searched a list of groups for the group holding that same entity. If the groups are in order, the first lookup checks one group and the last checks all 3,000. That’s &lt;strong&gt;4,501,500 comparisons&lt;/strong&gt; to reconnect 3,000 entities to groups that already hold their original entity. Profiling also turned up an earlier stage where each parent scanned the relation-ID rows. A separate contributor, skpn, had already documented the same behavior and proposed an indexed implementation. &lt;a href="https://github.com/typeorm/typeorm/issues/13112" rel="noopener noreferrer"&gt;Loadwise finding and profiling&lt;/a&gt; · &lt;a href="https://github.com/typeorm/typeorm/issues/13062" rel="noopener noreferrer"&gt;Earlier independent report&lt;/a&gt; · &lt;a href="https://github.com/typeorm/typeorm/pull/13063" rel="noopener noreferrer"&gt;Earlier proposed fix&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The proposal in PR #13116 builds indexes for ordinary keys, walks the related entities in their loaded order, and assigns each group’s result directly to its original entity. At 3,000 authors, an earlier revision recorded &lt;strong&gt;18.0 ms&lt;/strong&gt; on the same SQL.js fixture. That number describes one dataset and one revision. If you benchmark your own loader, keep the number of children per parent fixed as you increase the parent count. Then try a parent with many children to expose extra copying or sorting inside each group. &lt;a href="https://github.com/typeorm/typeorm/pull/13116" rel="noopener noreferrer"&gt;Proposed implementation, benchmark conditions, and tests&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The hard part is deciding what counts as the same key. Two JavaScript objects containing identical bytes can be distinct &lt;code&gt;Map&lt;/code&gt; keys. The database driver may consider them equal. An automated PR review raised an even subtler case: a binary ID subclass can override its hex formatter and produce a different string for the same bytes. A regression test for an index should compare its results with the old matcher on inputs like these. Check the child order and duplicate links as well as the number of matches. &lt;a href="https://github.com/typeorm/typeorm/pull/13116#discussion_r4727286323" rel="noopener noreferrer"&gt;Binary-key review comment&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As of November 30, 2026, PR #13116 was open and awaiting review. &lt;a href="https://github.com/typeorm/typeorm/pull/13116" rel="noopener noreferrer"&gt;Current PR status&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To check your own JavaScript or TypeScript project, run &lt;code&gt;npx loadwise@0.7.0 check --only perf&lt;/code&gt; from its root. For regular use, install the &lt;a href="https://www.npmjs.com/package/loadwise" rel="noopener noreferrer"&gt;npm package&lt;/a&gt; with &lt;code&gt;npm install --save-dev loadwise&lt;/code&gt;. &lt;a href="https://github.com/IbrahimHafez1/loadwise/issues/203" rel="noopener noreferrer"&gt;Share one useful finding or a false positive&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Disclosure: This article was generated with AI from the linked issues, benchmarks, and code review. The author of PR #13116 maintains Loadwise and disclosed AI assistance on the proposal.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>node</category>
      <category>database</category>
      <category>performance</category>
    </item>
    <item>
      <title>When a Node CLI exits successfully after its server fails to start</title>
      <dc:creator>Ibrahim Hafez</dc:creator>
      <pubDate>Tue, 01 Dec 2026 07:35:41 +0000</pubDate>
      <link>https://dev.to/ibrahimhafez1/when-a-node-cli-exits-successfully-after-its-server-fails-to-start-354e</link>
      <guid>https://dev.to/ibrahimhafez1/when-a-node-cli-exits-successfully-after-its-server-fails-to-start-354e</guid>
      <description>&lt;p&gt;A process exit code is part of a CLI’s public API. Consider a wrapper that starts a server and checks for success. What should it do if the child exits with code 0 but never prints the endpoint it promised?&lt;/p&gt;

&lt;p&gt;That happened in Playwright’s &lt;code&gt;launch-server&lt;/code&gt; command. With a missing configuration file and Node’s &lt;code&gt;warn&lt;/code&gt; policy for unhandled promise rejections, the process printed a warning, produced no WebSocket endpoint, and exited 0. With Node’s default policy, the same input exited 1. A test running only under the default would have passed. &lt;a href="https://github.com/microsoft/playwright/issues/44433" rel="noopener noreferrer"&gt;Public issue and minimal reproduction&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Where the promise went
&lt;/h3&gt;

&lt;p&gt;Loadwise flagged a call inside an async CLI action. The action called the function that starts the browser server, then reached the end of its own body. Marking the action async gives the &lt;em&gt;action&lt;/em&gt; a promise. For a startup failure to reach its caller, the action still has to await or return the startup promise, or send its rejection to the CLI’s error handler. A neighboring command already used that handler. &lt;a href="https://github.com/microsoft/playwright/blob/a804c193562095b0da20e5d4679fa87e4c8e5563/packages/playwright-core/src/cli/program.ts#L198-L205" rel="noopener noreferrer"&gt;Source at the reported revision&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What to assert in a Node CLI test
&lt;/h3&gt;

&lt;p&gt;Start the CLI as a child process with a known missing config file. Check three things together:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The child exits with the expected failure code.&lt;/li&gt;
&lt;li&gt;Its diagnostic names the missing file. Otherwise a broken test setup, such as pointing Node at the wrong CLI, can produce the same nonzero exit.&lt;/li&gt;
&lt;li&gt;It never emits a server endpoint. For the positive case, use a valid config, connect to the endpoint, and close the server.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Run the failure case under both &lt;code&gt;warn&lt;/code&gt; and &lt;code&gt;throw&lt;/code&gt;. That distinguishes an error the CLI handles deliberately from one that happens to terminate Node under a particular runtime policy.&lt;/p&gt;

&lt;p&gt;Playwright’s triage automation independently reproduced the result on Windows and opened a draft fix using the existing CLI error handler. The upstream thread includes its browser and configuration test matrix. &lt;a href="https://github.com/microsoft/playwright/issues/44433#issuecomment-7287509861" rel="noopener noreferrer"&gt;Verification&lt;/a&gt; · &lt;a href="https://github.com/microsoft/playwright/pull/44451" rel="noopener noreferrer"&gt;Proposed fix&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Try it in your own project
&lt;/h3&gt;

&lt;p&gt;From the root of a Node.js or TypeScript project, run a read-only reliability scan:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx loadwise@0.7.0 check --only rel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For regular use, install the npm package as a dev dependency with &lt;code&gt;npm install --save-dev loadwise@0.7.0&lt;/code&gt;. Then run &lt;code&gt;npx loadwise check&lt;/code&gt; for the full scan. &lt;a href="https://www.npmjs.com/package/loadwise" rel="noopener noreferrer"&gt;Loadwise on npm&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After your scan, &lt;a href="https://github.com/IbrahimHafez1/loadwise/issues/203" rel="noopener noreferrer"&gt;share one useful finding or one false positive&lt;/a&gt;. The rule ID and a sentence about what you fixed, or why the code was already safe, are enough. An anonymized example is welcome.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Disclosure: This article was generated with AI from the linked source, reproduction, and upstream review. The issue reporter maintains Loadwise.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>testing</category>
      <category>node</category>
      <category>javascript</category>
      <category>playwright</category>
    </item>
  </channel>
</rss>
