iisnode encountered an error when processing the request.

HRESULT: 0x6d
HTTP status: 500
HTTP subStatus: 1013
HTTP reason: Internal Server Error

You are receiving this HTTP 200 response because system.webServer/iisnode/@devErrorsEnabled configuration setting is 'true'.

In addition to the log of stdout and stderr of the node.exe process, consider using debugging and ETW traces to further diagnose the problem.

The last 64k of the output generated by the node.exe process to stderr is shown below:

(node:23836) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 unhandledRejection listeners added to [process]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
(node:23836) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(node:23836) NOTE: We are formalizing our plans to enter AWS SDK for JavaScript (v2) into maintenance mode in 2023.

Please migrate your code to use AWS SDK for JavaScript (v3).
For more information, check the migration guide at https://a.co/7PzMCcy
sql query execution error:

WITH cteOwner AS (
    SELECT '55B3A73D-5E53-4F94-9ADF-5498D4FEB32C' AS [owner]
),
cteMainQuery AS(
    SELECT
        uuid, title, public_id, brand, unit, is_virtual, tag_festival, tag_new, is_advanced_product, directory_id, is_available_on_webshop, created_at,
        cover_image,
        ISNULL(sell_price, 0) [sell_price], ISNULL(sell_price2, 0) [sell_price2], ISNULL(sell_price3, 0) [sell_price3], ISNULL(discount, 0) [discount],
        product_variation_count,
        IIF(is_available_on_webshop=0, 0, total_stock) AS total_stock,
        max_discount,
        sku_combined,
        _is_last,
        _r
    FROM (
        SELECT prd.*,
            (SELECT TOP 1 url FROM Media WHERE owner='55B3A73D-5E53-4F94-9ADF-5498D4FEB32C' AND is_deleted=0 AND type='product_pic' AND Media.product_id=prd.uuid ORDER BY is_cover DESC, list_order, created_at) AS cover_image,
            cheapest_variation.*,
            variation_info.product_variation_count,
            variation_info.total_stock,
            variation_info.max_discount,
            variation_info.sku_combined,
            (CASE WHEN COUNT(*) OVER (PARTITION BY NULL) = ROW_NUMBER() OVER (ORDER BY (CASE WHEN total_stock > 0 THEN 1 ELSE 0 END) DESC, created_at DESC) THEN 1 ELSE 0 END) AS _is_last,
            ROW_NUMBER() OVER (ORDER BY (CASE WHEN total_stock > 0 THEN 1 ELSE 0 END) DESC, created_at DESC) AS _r
        FROM [Product] AS prd

        INNER JOIN (
            SELECT product_id, sell_price, sell_price2, sell_price3, discount FROM (
                SELECT *, ROW_NUMBER() OVER (PARTITION BY ProductVariation.product_id ORDER BY (CASE WHEN sell_price > 0 THEN 0 ELSE 1 END), sell_price) row_num FROM ProductVariation
                WHERE owner=(SELECT owner FROM cteOwner) AND is_deleted=0 
            ) AS _
            WHERE row_num = 1
        ) AS cheapest_variation
        ON prd.uuid = cheapest_variation.product_id

        INNER JOIN (
            SELECT pv.product_id,
                SUM(pvStock._stock) total_stock,
                IIF(MIN(pv.discount) < 0, MIN(pv.discount), MAX(pv.discount)) max_discount,
				COUNT(pv.uuid) product_variation_count,
                STRING_AGG(CONCAT(pv.sku_prefix, pv.sku_suffix), ' ') sku_combined
            FROM ProductVariation pv
            INNER JOIN V_ProductVariation_Stock_For_Webshop pvStock ON pv.uuid = pvStock.product_variation_id
            WHERE pv.owner='55B3A73D-5E53-4F94-9ADF-5498D4FEB32C' AND pv.is_deleted=0
                AND 1=1
            GROUP BY pv.product_id
        ) AS variation_info
        ON prd.uuid = variation_info.product_id

        

        WHERE prd.owner='55B3A73D-5E53-4F94-9ADF-5498D4FEB32C'
            AND prd.is_deleted=0 AND prd.active_for_webshop=1 AND prd.is_archived=0
            
            AND 1=1 AND 1=1 AND 1=1 AND directory_id IN ('57582875-1CB7-45D1-8B1B-1B97AF650BDF')
    ) AS view1
),
cteGrouped AS (
    SELECT *, 'browse' AS _category FROM cteMainQuery
    WHERE _r > 0 AND _r <= 36
        -- AND ${where_browse}
    
)

SELECT * FROM cteGrouped
WHERE 1=1
ORDER BY _category, (CASE WHEN total_stock > 0 THEN 1 ELSE 0 END) DESC, created_at DESC
{"code":"EREQUEST","originalError":{"sqlstate":"HYT00","code":0,"severity":0,"serverName":"","procName":"","lineNumber":0},"name":"RequestError","number":0,"lineNumber":0,"state":"HYT00","class":0,"serverName":"","procName":""}
RequestError: Query timeout expired
    at handleError (C:\inetpub\TX_Kalaban\node_modules\mssql\lib\msnodesqlv8\request.js:276:21)
    at StreamEvents.emit (node:events:514:28)
    at StreamEvents.emit (node:domain:488:12)
    at C:\inetpub\TX_Kalaban\node_modules\msnodesqlv8\lib\reader.js:83:20
    at Array.forEach (<anonymous>)
    at Query.routeStatementError (C:\inetpub\TX_Kalaban\node_modules\msnodesqlv8\lib\reader.js:73:19)
    at C:\inetpub\TX_Kalaban\node_modules\msnodesqlv8\lib\reader.js:239:12
    at C:\inetpub\TX_Kalaban\node_modules\msnodesqlv8\lib\driver.js:191:13
    at Immediate.<anonymous> (C:\inetpub\TX_Kalaban\node_modules\msnodesqlv8\lib\driver.js:167:9)
    at process.processImmediate (node:internal/timers:478:21)