Skip to content

Fix #406: Prevent multiple server sessions at startup - #408

Open
isc-klu wants to merge 7 commits into
intersystems:masterfrom
isc-klu:queue-rest-requests
Open

Fix #406: Prevent multiple server sessions at startup#408
isc-klu wants to merge 7 commits into
intersystems:masterfrom
isc-klu:queue-rest-requests

Conversation

@isc-klu

@isc-klu isc-klu commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Problem

When VS Code opens with many tabs, each tab concurrently calls makeRESTRequest(), creating multiple sessions to the same server.

Solution

Serialize REST requests per server using promise-based queueing:

  • First request authenticates and stores session cookie
  • Concurrent requests wait and reuse the session cookie
  • Subsequent requests use cached cookies immediately

Changes

  • Changed cookiesCache to store promises instead of raw cookie arrays
  • Made getCookies()/updateCookies() async with queue logic
  • Added updateCookies() in catch block to ensure promises always resolve

@isc-klu
isc-klu requested a review from isc-bsaviano as a code owner July 7, 2026 21:10
@isc-bsaviano

Copy link
Copy Markdown
Collaborator

Sorry for nor reviewing this sooner KC. I think a more simple solution is to create sessions for all current workspace folders on activation. If we do it before activation completes then we know that all intellisense requests will be using cookies since those requests won't be sent until after activation. We can add a code block here that is similar to the the one from the main extension. The we won't need to modify any other code.

isc-klu and others added 5 commits July 24, 2026 10:03
Per review feedback on intersystems#408: rather than serializing REST requests via a
promise-based cookie cache, establish one session per workspace folder
during activation, before it completes. IntelliSense requests aren't sent
until after activation finishes, so they all reuse these sessions instead
of each creating a new one when many editor tabs are open at startup (intersystems#406).

Reverts the queueing changes to makeRESTRequest.ts and extracts the spec
resolution logic into a reusable helper.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Per Brett's review of intersystems#408: rather than serializing REST requests via a
promise-based cookie cache, create a session for each workspace folder
during activation, before it completes. IntelliSense requests aren't sent
until after activation finishes, so they all reuse these sessions instead
of each creating a new one when many editor tabs are open at startup (intersystems#406).

The resolveFromUri handler body is extracted into a resolveServerSpec helper
so the activation loop can reuse it; no other code is modified.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@isc-klu

isc-klu commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator Author

Sorry for nor reviewing this sooner KC. I think a more simple solution is to create sessions for all current workspace folders on activation. If we do it before activation completes then we know that all intellisense requests will be using cookies since those requests won't be sent until after activation. We can add a code block here that is similar to the the one from the main extension. The we won't need to modify any other code.

Thanks for the guidance. Please check the latest diff.

Comment thread client/src/extension.ts Outdated
Comment thread client/src/extension.ts Outdated
Comment thread client/src/extension.ts Outdated
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.

2 participants