Skip to content

⚡ Bolt: Parallelize session destruction in Node.js SDK#1

Merged
AkCodes23 merged 1 commit intomainfrom
bolt-parallel-stop-nodejs-13836018781846015088
Feb 7, 2026
Merged

⚡ Bolt: Parallelize session destruction in Node.js SDK#1
AkCodes23 merged 1 commit intomainfrom
bolt-parallel-stop-nodejs-13836018781846015088

Conversation

@AkCodes23
Copy link
Owner

⚡ Bolt: Parallelize session destruction in Node.js SDK

Optimized the stop() method in CopilotClient to destroy all active sessions in parallel using Promise.all.

Previously, sessions were destroyed sequentially, leading to a linear increase in shutdown time as the number of sessions grew. This was especially problematic given the existing retry logic and exponential backoff for each session destruction attempt.

With this change, the total time for session destruction is now independent of the number of sessions.

Measurements (using a mock benchmark):

  • 10 sessions with 100ms destruction delay:
    • Before: ~1000ms
    • After: ~100ms
  • Performance gain: ~10x improvement for 10 sessions.

The implementation ensures that:

  1. All sessions are cleaned up concurrently.
  2. Individual retry logic and backoff are maintained for each session.
  3. All errors encountered during destruction are still collected and returned.
  4. this.sessions is cleared only after all destruction attempts have finished.

Verified with existing unit tests and client E2E tests.


PR created automatically by Jules for task 13836018781846015088 started by @AkCodes23

Optimized the `stop()` method in `CopilotClient` to destroy all active
sessions in parallel using `Promise.all`.

Previously, sessions were destroyed sequentially, leading to a linear
increase in shutdown time as the number of sessions grew. With this
change, the total time for session destruction is approximately the
duration of the slowest individual destruction.

Measurements:
- 10 sessions with 100ms destruction delay:
  - Before: ~1000ms
  - After: ~100ms
- Performance gain: ~10x for 10 sessions.

The individual retry logic and exponential backoff for each session
are preserved. All failures are still collected and reported.

Co-authored-by: AkCodes23 <135016848+AkCodes23@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 6, 2026 17:52
@google-labs-jules
Copy link

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Improves shutdown performance in the Node.js SDK by parallelizing session cleanup in CopilotClient.stop() so session destruction time does not grow linearly with the number of active sessions.

Changes:

  • Parallelized session destruction by running per-session retry/backoff logic concurrently via Promise.all.
  • Preserved existing behavior of collecting and returning cleanup errors after all session-destruction attempts finish.
  • Added a Bolt learning note documenting the cross-SDK pattern and recommended parallel cleanup approach.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
nodejs/src/client.ts Updates CopilotClient.stop() to destroy all active sessions in parallel while preserving retry/backoff and aggregating errors.
.jules/bolt.md Documents the sequential-destruction performance issue and the recommended parallel cleanup strategy across SDKs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@AkCodes23 AkCodes23 merged commit e436065 into main Feb 7, 2026
6 checks passed
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.

1 participant