Skip to content

[Bug]: Concurrent requests for different queries receive each other's data #850

Description

@thisisanubhav

Description

fetchGitLabData and fetchCodebergData de-duplicate concurrent requests by queueing a caller onto whatever fetch is already in flight — but they do it without checking whether the in-flight fetch is for the same query. A caller asking for a different username, date range, org or repo filter is handed the other query's data.

if (!isCacheKeyMatch) {
    this.cache.data = null;          // we know the key differs...
}

if (this.cache.fetching) {
    return new Promise((resolve, reject) => {
        this.cache.queue.push({ resolve, reject });   // ...but queue anyway
    });
}

The line above it nulls the cached data precisely because the key differs, and then the caller is queued onto the unrelated fetch regardless.

Reproduction

With a fetch already in flight for one query, calling for a different one:

queued:   1
received: "DATA-BELONGING-TO-OTHER-QUERY"

The second caller resolves with the first query's result.

Impact

Generate a report, then change the date range (or org, or repo filter) and generate again before the first request finishes — the second report is built from the first query's data. Nothing errors and nothing looks wrong; the report just covers the wrong period. For a tool whose entire output is "what I did between these dates", silently reporting a different range is a bad failure mode.

Both helpers share the structure, so both are affected. githubHelper.js uses a different caching path and is not.

Expected

A caller should only share an in-flight request when it is asking for the same thing. A caller asking for something else should get its own request, not the other one's answer.

I have a fix and unit tests ready and will open a PR.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions