-
Notifications
You must be signed in to change notification settings - Fork 211
fix: Honor AbortSignal on Actor-MCP calls and hash-dedupe proxy names #1185
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
Merged
vojtechj-apify
merged 2 commits into
apify:master
from
Ayush7614:fix/actor-mcp-abort-and-proxy-names
Aug 4, 2026
Merged
Changes from all commits
Commits
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,51 @@ | ||
| import { createHash } from 'node:crypto'; | ||
|
|
||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import { MAX_TOOL_NAME_LENGTH, SERVER_ID_LENGTH, TOOL_NAME_HASH_LENGTH } from '../../src/mcp/const.js'; | ||
| import { getMCPServerID, getProxyMCPServerToolName } from '../../src/mcp/proxy.js'; | ||
|
|
||
| describe('getMCPServerID()', () => { | ||
| it('returns a stable SERVER_ID_LENGTH hex prefix of sha256(url)', () => { | ||
| const url = 'https://example.com/mcp'; | ||
| const expected = createHash('sha256').update(url).digest('hex').slice(0, SERVER_ID_LENGTH); | ||
| expect(getMCPServerID(url)).toBe(expected); | ||
| expect(getMCPServerID(url)).toBe(getMCPServerID(url)); | ||
| }); | ||
|
|
||
| it('keys by URL so SSE and streamable endpoints stay distinct', () => { | ||
| expect(getMCPServerID('https://actor.example/sse')).not.toBe(getMCPServerID('https://actor.example/mcp')); | ||
| }); | ||
| }); | ||
|
|
||
| describe('getProxyMCPServerToolName()', () => { | ||
| const url = 'https://example.com/mcp'; | ||
|
|
||
| it('returns prefix-toolName when under the length cap', () => { | ||
| const name = getProxyMCPServerToolName(url, 'list-items'); | ||
| expect(name).toBe(`${getMCPServerID(url)}-list-items`); | ||
| expect(name.length).toBeLessThanOrEqual(MAX_TOOL_NAME_LENGTH); | ||
| }); | ||
|
|
||
| it('hash-suffixes over-length names instead of bare truncation', () => { | ||
| const longTool = `very-long-origin-tool-name-${'x'.repeat(80)}`; | ||
| const fullName = `${getMCPServerID(url)}-${longTool}`; | ||
| const hash = createHash('sha256').update(fullName).digest('hex').slice(0, TOOL_NAME_HASH_LENGTH); | ||
| const name = getProxyMCPServerToolName(url, longTool); | ||
|
|
||
| expect(name.length).toBe(MAX_TOOL_NAME_LENGTH); | ||
| expect(name.endsWith(`-${hash}`)).toBe(true); | ||
| // Bare slice would drop the distinguishing suffix and collide; hash must survive. | ||
| expect(name).not.toBe(fullName.slice(0, MAX_TOOL_NAME_LENGTH)); | ||
| }); | ||
|
|
||
| it('keeps two over-length origin names distinct after capping', () => { | ||
| const sharedPrefix = `shared-prefix-${'y'.repeat(80)}`; | ||
| const a = getProxyMCPServerToolName(url, `${sharedPrefix}-alpha`); | ||
| const b = getProxyMCPServerToolName(url, `${sharedPrefix}-beta`); | ||
|
|
||
| expect(a).not.toBe(b); | ||
| expect(a.length).toBe(MAX_TOOL_NAME_LENGTH); | ||
| expect(b.length).toBe(MAX_TOOL_NAME_LENGTH); | ||
| }); | ||
| }); |
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.