-
-
Notifications
You must be signed in to change notification settings - Fork 56
docs: document async loading sub-parameters #398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
adity982
wants to merge
4
commits into
1mcp-app:main
Choose a base branch
from
adity982:agent/document-async-loading-options
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
83a355e
docs: document async loading options
adity982 8dc8099
Merge remote-tracking branch 'origin/main' into agent/document-async-…
adity982 0249dd1
fix(serve): align async loading options with snapshot semantics
adity982 6f91db7
fix(serve): validate async loading settings
adity982 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import { describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| import { resolveAsyncLoadingOptions } from './asyncLoadingOptions.js'; | ||
|
|
||
| describe('resolveAsyncLoadingOptions', () => { | ||
| it('uses snapshot notification defaults without deprecation warnings', () => { | ||
| const warn = vi.fn(); | ||
|
|
||
| const result = resolveAsyncLoadingOptions({}, undefined, warn); | ||
|
|
||
| expect(result).toMatchObject({ | ||
| enabled: false, | ||
| notifyOnServerReady: true, | ||
| waitForMinimumServers: 0, | ||
| initialLoadTimeoutMs: 30000, | ||
| }); | ||
| expect(warn).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('treats deprecated CLI or environment thresholds as warning-only no-ops', () => { | ||
| const warn = vi.fn(); | ||
|
|
||
| const result = resolveAsyncLoadingOptions({ 'async-min-servers': 12, 'async-timeout': 1 }, undefined, warn); | ||
|
|
||
| expect(result.waitForMinimumServers).toBe(0); | ||
| expect(result.initialLoadTimeoutMs).toBe(30000); | ||
| expect(warn).toHaveBeenCalledTimes(2); | ||
| expect(warn.mock.calls.join('\n')).toContain('ONE_MCP_ASYNC_MIN_SERVERS'); | ||
| expect(warn.mock.calls.join('\n')).toContain('ONE_MCP_ASYNC_TIMEOUT'); | ||
| }); | ||
|
|
||
| it('warns for deprecated TOML thresholds without consuming their values', () => { | ||
| const warn = vi.fn(); | ||
|
|
||
| const result = resolveAsyncLoadingOptions({}, { minServers: 4, timeout: 9000 }, warn); | ||
|
|
||
| expect(result.waitForMinimumServers).toBe(0); | ||
| expect(result.initialLoadTimeoutMs).toBe(30000); | ||
| expect(warn.mock.calls.join('\n')).toContain('asyncLoading.minServers'); | ||
| expect(warn.mock.calls.join('\n')).toContain('asyncLoading.timeout'); | ||
| }); | ||
|
|
||
| it('supports the deprecated notification alias with a warning', () => { | ||
| const warn = vi.fn(); | ||
|
|
||
| const result = resolveAsyncLoadingOptions({ 'async-notify-on-ready': false }, undefined, warn); | ||
|
|
||
| expect(result.notifyOnServerReady).toBe(false); | ||
| expect(warn).toHaveBeenCalledOnce(); | ||
| }); | ||
|
|
||
| it('gives the canonical snapshot flag precedence over the deprecated alias', () => { | ||
| const warn = vi.fn(); | ||
|
|
||
| const result = resolveAsyncLoadingOptions( | ||
| { | ||
| 'async-notify-on-snapshot': false, | ||
| 'async-notify-on-ready': true, | ||
| }, | ||
| undefined, | ||
| warn, | ||
| ); | ||
|
|
||
| expect(result.notifyOnServerReady).toBe(false); | ||
| expect(warn).toHaveBeenCalledOnce(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| export interface AsyncLoadingCliOptions { | ||
| 'enable-async-loading'?: boolean; | ||
| 'async-min-servers'?: number; | ||
| 'async-timeout'?: number; | ||
| 'async-batch-notifications'?: boolean; | ||
| 'async-batch-delay'?: number; | ||
| 'async-notify-on-snapshot'?: boolean; | ||
| 'async-notify-on-ready'?: boolean; | ||
| } | ||
|
|
||
| export interface AsyncLoadingAppOptions { | ||
| enabled?: boolean; | ||
| minServers?: number; | ||
| timeout?: number; | ||
| batchNotifications?: boolean; | ||
| batchDelay?: number; | ||
| } | ||
|
|
||
| export interface ResolvedAsyncLoadingOptions { | ||
| enabled: boolean; | ||
| notifyOnServerReady: boolean; | ||
| waitForMinimumServers: number; | ||
| initialLoadTimeoutMs: number; | ||
| batchNotifications: boolean; | ||
| batchDelayMs: number; | ||
| } | ||
|
|
||
| const DEPRECATED_INPUTS = { | ||
| minServers: | ||
| '`--async-min-servers`, `ONE_MCP_ASYNC_MIN_SERVERS`, and `asyncLoading.minServers` are deprecated compatibility no-ops', | ||
| timeout: '`--async-timeout`, `ONE_MCP_ASYNC_TIMEOUT`, and `asyncLoading.timeout` are deprecated compatibility no-ops', | ||
| } as const; | ||
|
|
||
| /** | ||
| * Resolve async-loading controls without treating compatibility settings as | ||
| * readiness gates. Yargs has already merged ONE_MCP_* values into cliOptions. | ||
| */ | ||
| export function resolveAsyncLoadingOptions( | ||
| cliOptions: AsyncLoadingCliOptions, | ||
| appOptions: AsyncLoadingAppOptions | undefined, | ||
| warn: (message: string) => void, | ||
| ): ResolvedAsyncLoadingOptions { | ||
| if (cliOptions['async-min-servers'] !== undefined || appOptions?.minServers !== undefined) { | ||
| warn(`DEPRECATION WARNING: ${DEPRECATED_INPUTS.minServers}; remove this setting before the next breaking release.`); | ||
| } | ||
| if (cliOptions['async-timeout'] !== undefined || appOptions?.timeout !== undefined) { | ||
| warn(`DEPRECATION WARNING: ${DEPRECATED_INPUTS.timeout}; remove this setting before the next breaking release.`); | ||
| } | ||
| if (cliOptions['async-notify-on-ready'] !== undefined) { | ||
| warn( | ||
| 'DEPRECATION WARNING: `--async-notify-on-ready` / `ONE_MCP_ASYNC_NOTIFY_ON_READY` is deprecated; use `--async-notify-on-snapshot` instead.', | ||
| ); | ||
| } | ||
|
|
||
| return { | ||
| enabled: cliOptions['enable-async-loading'] ?? appOptions?.enabled ?? false, | ||
| // The canonical spelling wins when both it and the compatibility alias are explicit. | ||
| notifyOnServerReady: cliOptions['async-notify-on-snapshot'] ?? cliOptions['async-notify-on-ready'] ?? true, | ||
| // Retained internal fields are deliberately fixed: neither is a readiness gate. | ||
| waitForMinimumServers: 0, | ||
| initialLoadTimeoutMs: 30000, | ||
| batchNotifications: cliOptions['async-batch-notifications'] ?? appOptions?.batchNotifications ?? true, | ||
| batchDelayMs: cliOptions['async-batch-delay'] ?? appOptions?.batchDelay ?? 100, | ||
| }; | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.