Skip to content

fix: make enterprise inner API timeout configurable - #39337

Merged
GareArc merged 3 commits into
release/e-1.11.4from
fix/cus-1422-enterprise-api-timeout-e-1114
Jul 21, 2026
Merged

fix: make enterprise inner API timeout configurable#39337
GareArc merged 3 commits into
release/e-1.11.4from
fix/cus-1422-enterprise-api-timeout-e-1114

Conversation

@GareArc

@GareArc GareArc commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Replaces #39334, whose branch sat under hotfix/** and could not be updated (the hotfix ruleset requires changes go through a PR).

Problem

Requests to the enterprise inner API relied on httpx's implicit 5s default. No call site passed timeout, and no env or config could change it.

On tenants with enough installed apps, POST /webapp/permission/batch exceeds that budget and /console/api/installed-apps fails with httpx.ReadTimeout, so the Explore page cannot render.

Change

Adds ENTERPRISE_REQUEST_TIMEOUT to EnterpriseFeatureConfig and passes it to client.request in BaseRequest.send_request.

The name and int type deliberately match what already exists on main (added in #33158, which is not an ancestor of this branch). Using a different name here would leave two env vars controlling one behavior after this branch merges forward, silently orphaning any deployment configured on the other name.

Default is 90 on this branch. The enterprise server enforces its own SERVER_TIMEOUT (default 60s), so a client budget above that lets the server terminate a runaway request first and return a clean 504 instead of the two timers racing.

Note this raises the effective budget for all enterprise inner-API calls on this branch, not just the batch permission one — a stalled enterprise pod holds a gunicorn worker longer than it used to.

Also included: unrelated CI fix

api/Dockerfile ran npm install -g npm@latest against a pinned NODE_PACKAGE_VERSION=22.22.0. npm 12 requires node ^22.22.2 || ^24.15.0 || >=26.0.0, so the install now fails with EBADENGINE and the API image cannot build:

npm error notsup Required: {"node":"^22.22.2 || ^24.15.0 || >=26.0.0"}
npm error notsup Actual:   {"npm":"10.9.4","node":"v22.22.0"}

This is a pre-existing float, not a regression from this change — the step passed on 2026-03-15 and broke when npm 12 raised its node floor. Pinned to npm@11 (engine >=22.9.0) so the build stops tracking npm's release schedule. Happy to split this into its own PR if preferred; it is bundled only because this PR cannot go green without it.

Scope

Mitigation, not a root-cause fix. It makes the Explore page slow rather than broken, and only when the request completes inside the window — the enterprise-side 60s cap still applies.

The underlying cause is a per-app N+1 in the enterprise permission/batch handler: it loops IsUserAllowedToAccessWebAppByAppID per app id, ~6 queries each, two of them against tables with no indexes. Fixed enterprise-side and tracked separately.

Main-branch equivalent: #39335.

Ref: CUS-1422

GareArc added 3 commits July 20, 2026 20:40
Requests to the enterprise inner API relied on httpx's implicit 5s default.
On tenants with many installed apps, POST /webapp/permission/batch exceeds
that budget and the Explore page fails with httpx.ReadTimeout.

Expose ENTERPRISE_API_TIMEOUT so the budget can be raised per deployment,
defaulting to 90s to sit above the enterprise server's own 60s request
timeout rather than racing it.
main already defines ENTERPRISE_REQUEST_TIMEOUT for the same purpose
(added in #33158, which is not an ancestor of this branch). Introducing
ENTERPRISE_API_TIMEOUT here would leave two env vars controlling one
behavior once this branch merges forward, silently orphaning any
deployment configured on the old name.

Match main's name and int type. The default stays 90 on this branch.
npm@latest resolves to 12.0.1, which requires node ^22.22.2 || ^24.15.0 ||
>=26.0.0. The image pins NODE_PACKAGE_VERSION=22.22.0, so the install fails
with EBADENGINE and the API build cannot complete.

The float is the defect: this step passed until npm 12 raised its node floor.
Pin the major so the build stops depending on npm's release schedule.
@GareArc
GareArc requested a review from QuantumGhost as a code owner July 21, 2026 03:52
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jul 21, 2026
@GareArc
GareArc merged commit 4854380 into release/e-1.11.4 Jul 21, 2026
2 checks passed
@GareArc
GareArc deleted the fix/cus-1422-enterprise-api-timeout-e-1114 branch July 21, 2026 03:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant