fix: make enterprise inner API timeout configurable - #39337
Merged
GareArc merged 3 commits intoJul 21, 2026
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces #39334, whose branch sat under
hotfix/**and could not be updated (thehotfixruleset 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/batchexceeds that budget and/console/api/installed-appsfails withhttpx.ReadTimeout, so the Explore page cannot render.Change
Adds
ENTERPRISE_REQUEST_TIMEOUTtoEnterpriseFeatureConfigand passes it toclient.requestinBaseRequest.send_request.The name and
inttype deliberately match what already exists onmain(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
90on this branch. The enterprise server enforces its ownSERVER_TIMEOUT(default60s), 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/Dockerfilerannpm install -g npm@latestagainst a pinnedNODE_PACKAGE_VERSION=22.22.0. npm 12 requires node^22.22.2 || ^24.15.0 || >=26.0.0, so the install now fails withEBADENGINEand the API image cannot build: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/batchhandler: it loopsIsUserAllowedToAccessWebAppByAppIDper 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