podium-lib / client

Client for fetching Podium component fragments over HTTP.
MIT License
7 stars 6 forks source link

Timeouts not working reliably #408

Closed leftieFriele closed 2 months ago

leftieFriele commented 2 months ago

Thee effect of setting a timeout in layout.client.register is unclear and does not seem to work predictably.

A timeout of 1 ms only causes a BodyTimeoutError on some requests.

Other times the request goes through. If we "patch" the podium HTTP client in http.js with an AbortSignal with the corresponding bodyTimeout the requests consistently fail as we expect:

async request(url, options) {
    const { statusCode, headers, body } = await request(
        new URL(url),
        {...options, signal: url.includes('manifest') ? undefined : AbortSignal.timeout(options.bodyTimeout)},
    );
    return { statusCode, headers, body };
}

Possibly related issue: https://github.com/nodejs/undici/issues/3297

digitalsadhu commented 2 months ago

Fixed in https://github.com/podium-lib/client/pull/409