static async getIssue()

in app/lib/githubService.ts [197:244]


  static async getIssue(
    repoUrl: string,
    issueNumber: number
  ): Promise<GitHubIssue | null> {
    const cacheKey = `${repoUrl}#${issueNumber}`;

    // Check cache first
    if (this.issueCache.has(cacheKey)) {
      return this.issueCache.get(cacheKey)!;
    }

    // Check if this request has failed too many times
    if (this.shouldSkipFailedRequest(cacheKey)) {
      return null;
    }

    // Check if request is already pending to avoid duplicate requests
    if (this.pendingRequests.has(cacheKey)) {
      try {
        return await this.pendingRequests.get(cacheKey);
      } catch (error) {
        return null;
      }
    }

    // Create and store the promise
    const requestPromise = this.fetchIssue(repoUrl, issueNumber);
    this.pendingRequests.set(cacheKey, requestPromise);

    try {
      const issue = await requestPromise;
      if (issue) {
        this.issueCache.set(cacheKey, issue);
        // Clear any previous failure record on success
        this.failedRequests.delete(cacheKey);
      } else {
        // Track failed request (404 or other issues)
        this.trackFailedRequest(cacheKey);
      }
      return issue;
    } catch (error) {
      console.warn("Failed to fetch GitHub issue:", error);
      this.trackFailedRequest(cacheKey);
      return null;
    } finally {
      this.pendingRequests.delete(cacheKey);
    }
  }