Skip to content

Conversation

@jamietanna
Copy link
Contributor

@jamietanna jamietanna commented Dec 1, 2025

Changes

When instrumenting, we specifically handle Promises. However, if we have
an object, like SimpleGit's Response:

export type Response<T> = SimpleGit & Promise<T>;

This does not get correctly instrumented, and we end up not waiting for
the function call to complete.

We can make sure we use isPromise to correctly check if it's a native
Promise, or something with a Promise-like API.

As an alternative to #39653.

Evidence

Before (git clone immediately returns):

Screenshot 2025-12-01 at 11 41 19

After (git clone returns correct timing)

Screenshot 2025-12-01 at 14 53 15

Context

Please select one of the below:

  • This closes an existing Issue: #
  • This doesn't close an Issue, but I accept the risk that this PR may be closed if maintainers disagree with its opening or implementation

AI assistance disclosure

Did you use AI tools to create any part of this pull request?

Please select one option and, if yes, briefly describe how AI was used (e.g., code, tests, docs) and which tool(s) you used.

  • No — I did not use AI for this contribution.
  • Yes — minimal assistance (e.g., IDE autocomplete, small code completions, grammar fixes).
  • Yes — substantive assistance (AI generated non‑trivial portions of code, tests, or documentation).
  • Yes — other (please describe):

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

The public repository:

When instrumenting, we specifically handle Promises. However, if we have
an object, like SimpleGit's `Response`:

```
export type Response<T> = SimpleGit & Promise<T>;
```

This does not get correctly instrumented, and we end up not waiting for
the function call to complete.

We can make sure we use `isPromise` to correctly check if it's a native
Promise, or something with a Promise-like API.
@jamietanna
Copy link
Contributor Author

Driving this through a test was a bit awkward, and I couldn't get it passing: #39663 is where I've started this, but given running it with a repository works, I think we should merge as-is

@jamietanna jamietanna added this pull request to the merge queue Dec 1, 2025
Merged via the queue into main with commit 7f6fcfb Dec 1, 2025
41 checks passed
@jamietanna jamietanna deleted the defect/instrumentation-promise branch December 1, 2025 15:06
@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2025

🎉 This PR is included in version 42.29.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

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