Skip to content

feat(bson-parsing): terminate worker if execution exceeds 2mins COMPASS-11147 - #893

Open
mabaasit wants to merge 6 commits into
restrict-worker-scopefrom
timout-long-running-worker
Open

mabaasit wants to merge 6 commits into
restrict-worker-scopefrom
timout-long-running-worker

Conversation

@mabaasit

@mabaasit mabaasit commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

Description

COMPASS-11147

Open Questions

Checklist


Stack created with GitHub Stacks CLI • Give Feedback 💬

@mabaasit
mabaasit requested review from a team as code owners September 21, 2026 08:51
@mabaasit
mabaasit added this pull request to stack #894 September 21, 2026 08:51
@mabaasit
mabaasit requested review from Anemy and removed request for a team September 21, 2026 08:51
/** Close the worker after being idle for 30sec */
const IDLE_TIMEOUT_MS = 30_000;
/** Default execution timeout for worker requests */
const DEFAULT_EXECUTION_TIMEOUT_MS = 120_000;

@Anemy Anemy Sep 21, 2026 •

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.

Should consumers be able to pass this timeout? Will 0 indicate no timeout?

@mabaasit mabaasit Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

That's a good idea, will implement this.

@mabaasit mabaasit changed the title feat(bson-parsing): terminate worker if execution exceeds 2mins feat(bson-parsing): terminate worker if execution exceeds 2mins COMPASS-11147 Sep 22, 2026
@mabaasit
mabaasit marked this pull request as draft September 22, 2026 08:58
Copilot AI lite review requested due to automatic review settings September 23, 2026 11:19
@mabaasit
mabaasit force-pushed the timout-long-running-worker branch from 2bce04b to 887c77d Compare September 23, 2026 11:19

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.

Copilot review overview

🟡 Changes recommended

Moderate worker-concurrency and test-environment cleanup issues remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 Medium severity · 2 Low severity

Open (4)
What changed in this PR

Adds configurable two-minute execution timeouts for BSON parser workers, including worker termination and slow-worker tests.

Changes:

  • Adds timeout handling and worker termination.
  • Exposes timeout options through the parser API.
  • Adds slow-worker fixtures, tests, and related dependency/lint configuration.
File Reviewed changes Findings
packages/​shell-bson-parser/​tsconfig-lint.json Excludes test fixtures from lint type checking. No findings.
packages/​shell-bson-parser/​test/​fixtures/​slow-worker.mjs Adds a deliberately slow worker fixture. No findings.
packages/​shell-bson-parser/​src/​worker-client.ts Implements request timers and worker termination. moderate (2 votes): global termination can target the wrong worker during concurrent initialization, leaving the timed-out worker active and leaking its blob URL. Initialization must be serialized or termination made instance-aware. nit (3 votes): correct the duplicated/incorrect verb in the comment.
packages/​shell-bson-parser/​src/​index.ts Exposes execution timeout options. No findings.
packages/​shell-bson-parser/​src/​index.spec.ts Adds timeout and worker replacement tests. moderate (3 votes, also line 233): restore or delete TEST_WORKER_SCRIPT_URL when initially unset. moderate (1 vote): the cleanup truthiness check leaks the override when initially undefined. nit (2 votes): correct the comment to say the request “times out.”
packages/​shell-bson-parser/​package.json Adds the worker test dependency. No findings.
packages/​shell-bson-parser/​.eslintrc.cjs Excludes fixture files from ESLint. No findings.
package-lock.json Locks the new dependency. No findings.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +50 to +52
if (initialWorkerScriptUrl) {
process.env.TEST_WORKER_SCRIPT_URL = initialWorkerScriptUrl;
}
Comment on lines +120 to +123
terminateWorker(
new Error(`Worker execution timed out after ${executionTimeoutMs}ms`),
);
}, executionTimeoutMs);
Comment thread packages/shell-bson-parser/src/index.spec.ts Outdated
Comment thread packages/shell-bson-parser/src/worker-client.ts Outdated
@mabaasit
mabaasit force-pushed the timout-long-running-worker branch 2 times, most recently from b96a2f9 to 0abaf9e Compare September 28, 2026 12:20
@mabaasit
mabaasit force-pushed the timout-long-running-worker branch from 0abaf9e to e27980e Compare September 28, 2026 12:33
@mabaasit
mabaasit force-pushed the timout-long-running-worker branch from e27980e to b211fce Compare September 28, 2026 12:38
@mabaasit
mabaasit marked this pull request as ready for review September 28, 2026 13:37
@mabaasit
mabaasit force-pushed the timout-long-running-worker branch from 3de38eb to 1a46cde Compare September 28, 2026 15:28
@mabaasit
mabaasit force-pushed the timout-long-running-worker branch 2 times, most recently from 14a71f4 to 697c416 Compare September 29, 2026 08:10
@mabaasit
mabaasit force-pushed the timout-long-running-worker branch from 697c416 to fcd4d37 Compare September 29, 2026 08:35
@mabaasit
mabaasit force-pushed the timout-long-running-worker branch from fcd4d37 to b654b01 Compare October 5, 2026 13:00
@mabaasit
mabaasit force-pushed the timout-long-running-worker branch from b654b01 to 4985a1e Compare October 5, 2026 13:04
@mabaasit
mabaasit force-pushed the timout-long-running-worker branch from 4985a1e to e718832 Compare October 5, 2026 13:19
@mabaasit
mabaasit force-pushed the timout-long-running-worker branch from e718832 to a932a6b Compare October 5, 2026 15:20
@mabaasit
mabaasit force-pushed the timout-long-running-worker branch from a932a6b to 72dbb6f Compare October 5, 2026 15:47
@mabaasit
mabaasit force-pushed the timout-long-running-worker branch from 72dbb6f to 15f62f1 Compare October 5, 2026 19:44
@mabaasit
mabaasit force-pushed the timout-long-running-worker branch from 15f62f1 to 1daa2a9 Compare October 5, 2026 20:30
@mabaasit
mabaasit force-pushed the timout-long-running-worker branch from 1daa2a9 to be00ce4 Compare October 8, 2026 21:42
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