Skip to content

fix(import): time out stalled GitLab organization requests - #1376

Merged
SaulMoro merged 2 commits into
Tencent:mainfrom
ydflow:fix/gitlab-org-request-timeout
Oct 25, 2026
Merged

SaulMoro merged 2 commits into
Tencent:mainfrom
ydflow:fix/gitlab-org-request-timeout

Conversation

@ydflow

@ydflow ydflow commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

GitLab group discovery in teamai import --from-org can keep waiting on a stalled response, including a later page after earlier projects have been collected. The listing has a size limit but no request deadline, so the import never reaches whitelist generation or its error handler.

Give each group-project page its own 30-second AbortSignal.timeout, covering headers and response-body consumption. A timeout rejects the listing before any partial whitelist is written or repository import starts. Keep the existing pagination, 50 MB body limit, redirect policy and HTTP errors. Update the English and Chinese knowledge guides.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Test Plan

  • npm run build
  • npx tsc --noEmit
  • npm run lint
  • git diff --check
  • On rebased head 786e4ba, npx vitest run src/__tests__/gitlab-org-timeout.test.ts src/__tests__/gitlab-provider.test.ts src/__tests__/import-org.test.ts src/__tests__/import-repo-list.test.ts --maxWorkers=1: 93 passed.
  • After building rebased head 786e4ba, npx vitest run --config vitest.e2e.config.ts src/__tests__/e2e/gitlab-org-timeout.test.ts src/__tests__/gitlab-org-prefix-e2e.test.ts src/__tests__/e2e/import-batch-concurrency.test.ts --maxWorkers=1 --retry=0: 16 passed.
  • Full native-Windows unit suite: not green and not completed. It was stopped after uninstall.test.ts reported 9 failures. All 9 reproduce in a separate pristine-upstream worktree at f3cd042 with the same dependencies (npx vitest run src/__tests__/uninstall.test.ts --maxWorkers=1 -t 'keeps the loader, the registry|for a config under a symlinked directory|removes the OpenCode rules globs|names the file and the error|does not delete through a linked': 9 failed, 207 skipped). They include Windows symlink permissions, loader cleanup and path assertions. No unrelated source or test assertions were changed.

Regression sensitivity: all six new unit cases fail on pristine upstream f3cd042. They use a real local HTTP server and shorten only the deadline, checking first/later-page stalls before headers and in both success/error bodies. The new built-CLI E2E also fails on the pristine upstream build: the stalled second page remains pending until the 45-second test watchdog terminates the CLI.

Real CLI with the fix: the second page stalls after sending headers and a partial JSON body. The built CLI exits 1 after the actual 30-second deadline; an existing whitelist remains byte-for-byte unchanged. Retrying against the recovered fixture exits 0 and writes all 101 repositories. Existing E2E cases also verify custom API prefixes, instance-root paths and normal pagination. No live GitLab account or model credentials are used.

Related Issues

Found while inspecting organization import and provider error handling. #1243 bounds GitLab MR requests; this applies the same deadline policy to the separate group-project listing path. No directly matching open issue or PR was found during triage.

Notes for Reviewers

Validation environment: Windows, Node 24.19.0. The production change is limited to GitLab organization discovery; the follow-up below hardens one existing CI test fixture.

#1363 merged while this PR was being validated. This branch is rebased on upstream b292f41; the organization-import and batch-concurrency checks above were rerun on the new baseline. Preflight reports no overlapping files with another open PR of mine.

CI cancellation fixture

The first Ubuntu Node 24 job at 5258a00 had one failure: the existing kills a cancelled command that ignores SIGTERM after the grace period, and finishes test exceeded its 15-second budget. All six new GitLab unit cases passed in that job. The same cancellation test passed in about 5.3 seconds on Node 20/22 and on an earlier Node 24 run. The log does not identify which phase exceeded the budget.

Commit 786e4ba hardens that one fixture:

  • Give this real-worktree test a 30-second budget, allowing for the production five-second SIGKILL grace period and Git setup; the global timeout is unchanged.
  • The finish command exits with a diagnostic after 10 seconds without the PID marker, instead of polling forever.
  • On a Vitest timeout, read the PID directly and stop the fixture child before the driver has returned. The old cleanup could only learn the PID after a successful return. Ordinary cleanup uses the same path.
  • Keep the successful end, cancelled/succeeded step states and child-exited assertions. No production stop behavior, retry policy or assertion was weakened.

Validation: the cancellation case passes locally on Windows; this does not exercise POSIX process groups. A separate local probe ran the exact generated finish script with/without its marker and ran the exact abort cleanup against a real child: success, bounded failure and cleanup before a driver result all passed. Build, type check, lint and the 93-unit/16-built-CLI checks above passed after rebase. The broad four-file Windows run completed with 166 passed, 38 failed and 3 skipped; the repaired cancellation case passed. The wider workflow file has POSIX-shell and permission failures on native Windows. Three representative failures also reproduce in a pristine f3cd042 worktree (runs setup once in the workspace it creates, gives each command only the env keys, leaves no secret value in the result file: 3 failed, 129 skipped); a full baseline rerun of all 38 failures was not performed. The new head's Linux/macOS CI verifies the POSIX path.
Completed CI on exact head 786e4ba: CI run 40179617804 finished successfully on 2026-10-25. All Ubuntu and macOS Node 20/22/24 jobs, Windows checks, Prepare build, Build and the three fork-safe E2E shards plus aggregate passed. Ubuntu jobs each passed 15,582 tests (129 configured skips); macOS jobs each passed 15,766 tests (25 configured skips). E2E passed 1,574 tests with 33 configured skips; the remote-credential E2E job was skipped by fork policy. The new GitLab timeout CLI case passed on Linux at the actual 30-second deadline. The previously failing cancellation test passed in 5,304 ms on Ubuntu Node 24 and 5,769–6,345 ms on macOS; the workflow-driver file passed all 132 tests on every matrix leg. The original failure remains linked above; this passing run does not identify the precise stalled phase of that earlier timeout.

@ydflow
ydflow force-pushed the fix/gitlab-org-request-timeout branch from 5258a00 to 786e4ba Compare October 25, 2026 09:11
@github-actions

Copy link
Copy Markdown

No findings in the specified diff.

The PR description satisfies the testing requirement: it documents a built-CLI run on head 786e4ba, including timeout failure, an unchanged whitelist, and a successful retry.

Review was read-only; I did not run, build, or install anything from the PR.

@SaulMoro SaulMoro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was generated by AI during triage.

@ydflow Approving at 786e4ba. With the built CLI against a local server whose second group-projects page stalls after the headers and part of the body, builds of the merge-base and of current main (6e4d8dc) are still waiting after 60 s. This head exits 1 after 30 s and leaves the existing whitelist unchanged, and the retry against the recovered server writes all 101 repositories. A stall before the headers also exits 1 after 30 s. tsc, lint, the changed unit files (259 tests) and both e2e files pass. The new unit cases fail 6/6 on the merge-base and the new e2e case fails there too.

  • [P2 non-blocking] The workflow-local-driver.test.ts change (budget raised from 15 s to 30 s, a deadline in the finish script, cleanup moved into an abort listener) is outside the GitLab fix. The body explains why, and the failed job's log shows only Test timed out in 15000ms, so the slow phase is still unknown. A separate PR would have kept this one surgical, as with the fixture change in #1363.
  • [P2 non-blocking] The timeout prints listOrgRepos failed: TimeoutError: The operation was aborted due to timeout, without the group, the page, the 30 s deadline or what to do next. The MR path from #1243 prints the same raw form, so this is not a regression. Naming the group and the deadline would make both actionable.
  • [P3 nit] REQUEST_TIMEOUT_MS is now declared in two files. It follows #1243's pattern; a shared constant would keep the two deadlines from drifting.

The GitHub org listing (gh-org.ts:49) has no deadline either. We read the code but did not run it, and it is outside this PR.

The CI review reports no findings. We agree that nothing blocks and that the testing record is real; we add the fixture-scope note. All CI jobs pass; the GitHub-provider job is skipped by the fork policy.

@SaulMoro
SaulMoro merged commit 13c891e into Tencent:main Oct 25, 2026
20 checks passed
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
)

* fix(import): bound GitLab organization list requests

* test(workflow): bound cancellation fixture waits and cleanup

---------

Co-authored-by: ydflow <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants