Skip to content

Fix incorrect last bytes sent API timing data from nested requests - #65449

Merged
Andrew Branch (andrewbranch) merged 2 commits into
microsoft:mainfrom
andrewbranch:sync-ipc-transport-benchmark
Nov 19, 2026
Merged

Andrew Branch (andrewbranch) merged 2 commits into
microsoft:mainfrom
andrewbranch:sync-ipc-transport-benchmark

Conversation

@andrewbranch

Copy link
Copy Markdown
Member

Noticed while working on something totally unrelated

Copilot AI balanced review requested due to automatic review settings November 12, 2026 00:40
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 12, 2026
@typescript-automation typescript-automation Bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Nov 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified for the nested-request sent-byte timing fix.

No open issues 🎉

What changed in this PR

Fixes sent-byte timing data in the synchronous TypeScript API when a callback issues a nested request.

Changes:

  • Restores the outer request’s sent-byte count when its response arrives.
  • Adds a regression test verifying that a larger nested request does not overwrite the outer request’s recorded size.
File Description
packages/​typescript/​test/​sync/​timing.test.ts Tests sent-byte timing for nested synchronous requests.
packages/​typescript/​src/​api/​syncChannel.ts Recalculates sent bytes from the current request payload before returning its response.

Review effort: Balanced

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems good, just wondering about the test.

Comment on lines +15 to +16
let api: API | undefined;
using instance = new API({

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why can't we use a single variable? Is this model just confused about how using works?

(am I just confused about how using works?)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Uh yeah this is weird

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fusion chose Luna 😑

Comment on lines +330 to +331
// A callback may have issued a nested request while waiting for this response.
this.lastBytesSent = typeof payload === "string"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And payload itself is the source of truth for the current request?

readFile: path => {
if (!nested) {
nested = true;
if (!api) throw new Error("API is not initialized");

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oh, it was spooked by the prospect of this running during initialization, but that's not what happens

@andrewbranch
Andrew Branch (andrewbranch) added this pull request to the merge queue Nov 19, 2026
@github-project-automation github-project-automation Bot moved this from Not started to Needs merge in PR Backlog Nov 19, 2026
Merged via the queue into microsoft:main with commit c30d3f9 Nov 19, 2026
34 checks passed
@andrewbranch
Andrew Branch (andrewbranch) deleted the sync-ipc-transport-benchmark branch November 19, 2026 17:04
@github-project-automation github-project-automation Bot moved this from Needs merge to Done in PR Backlog Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants