Skip to content

Fix race condition in observer failure test, re-enable remoteServiceBrokerTests#427

Open
Copilot wants to merge 3 commits into
mainfrom
copilot/stabilize-remote-service-broker-tests
Open

Fix race condition in observer failure test, re-enable remoteServiceBrokerTests#427
Copilot wants to merge 3 commits into
mainfrom
copilot/stabilize-remote-service-broker-tests

Conversation

Copilot AI commented Feb 24, 2026

Copy link
Copy Markdown

The entire remoteServiceBrokerTests.ts suite was disabled (describe.skip) in #372 due to consistent failures in CI.

Root cause

The "with failure end" observer test had a race condition: assert.rejects caught the inner promise rejection (from the observer's onError callback) before the observeNumbers RPC response arrived. The test then proceeded to dispose resources while a sendRequest promise was still pending in vscode-jsonrpc's responsePromises map. On channel teardown, dispose() rejected these orphaned promises, producing unhandled rejections that bled into the next test block.

Changes

  • Re-enable the test suite — remove describe.skip/*unstable*/
  • Fix the "with failure end" test — await observeNumbers completion before disposing, eliminating the race between promise rejection and RPC response arrival. Add explicit proxy?.dispose() before broker.dispose() (matching the "with successful end" test).

Before (races):

await assert.rejects(
  new Promise(async (resolve, reject) => {
    const observer = new Observer(v => ..., err => { reject(err) })
    await proxy?.observeNumbers(observer, 3, true) // response arrives after reject()
  })
)
broker.dispose() // pending RPC → unhandled PendingResponseRejected

After:

const failObserver = new Observer(v => ..., err => { collectedErrors.push(err) })
await proxy?.observeNumbers(failObserver, 3, true) // completes before cleanup
assert.strictEqual(collectedErrors.length, 1)
proxy?.dispose()
broker.dispose()

Verified stable across 20 consecutive runs.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • xofvsblobprodwus2114.vsblob.vsassets.io
    • Triggering command: /opt/hostedtoolcache/dotnet/dotnet dotnet build test/ServiceBrokerTest/ServiceBrokerTest.csproj -c Release (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>remoteServiceBrokerTests.ts tests need to be stabilized and re-enabled</issue_title>
<issue_description>#372 disables a whole file of tests because they consistently fail when run in the devdiv account (though they usually pass in the azure-public account for some reason).

We should investigate these failures and re-enable the tests.</issue_description>

<agent_instructions>Analyze the tests for potential sources of instability, fix them, then run them 20 times in a row. If you can fix them so that they pass 20 times in a row, leave them enabled and send a PR with your changes.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 24, 2026 17:13
… observer failure test, re-enable test suite

The "with failure end" observer test had a race condition where assert.rejects would
catch the inner promise rejection (from the observer's onError callback) before the
observeNumbers RPC response arrived. This left a pending response on the service
channel's RPC connection, causing a PendingResponseRejected unhandled rejection
that bled into subsequent tests.

Fix: Restructure the test to await observeNumbers completion before disposing,
and add explicit proxy disposal (matching the "with successful end" test pattern).
Also re-enable the entire test suite by removing describe.skip.

Co-authored-by: AArnott <3548+AArnott@users.noreply.github.com>
…olon prefix

Co-authored-by: AArnott <3548+AArnott@users.noreply.github.com>
Copilot AI changed the title [WIP] Stabilize and re-enable remoteServiceBrokerTests.ts tests Fix race condition in observer failure test, re-enable remoteServiceBrokerTests Feb 24, 2026
@AArnott AArnott marked this pull request as ready for review February 24, 2026 18:30
@AArnott AArnott requested a review from Copilot February 24, 2026 18:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a race condition in the "with failure end" observer test and re-enables the entire remoteServiceBrokerTests.ts test suite that was disabled in PR #372 due to consistent CI failures.

Changes:

  • Re-enabled the test suite by removing describe.skip/*unstable*/
  • Fixed race condition in the "with failure end" observer test by changing from assert.rejects pattern to explicit error collection
  • Added proper disposal ordering (proxy?.dispose() before broker.dispose()) to match the pattern in "with successful end" test

@AArnott AArnott enabled auto-merge (squash) February 24, 2026 19:20
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.

remoteServiceBrokerTests.ts tests need to be stabilized and re-enabled

3 participants