`_onprogress` raises a protocol error for a race servers cannot avoid (progress notification arriving with the response)
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 68/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- typescript
- Ambito
- api
Direzione di ricerca
Inizia in src/shared/protocol.ts leggendo _onresponse e _onprogress, quindi riproduci la race con l’esempio callTool e i messaggi di avanzamento e risposta adiacenti. Il lavoro è completato quando una notifica di avanzamento tardiva per una richiesta completata viene scartata senza attivare _onerror, mentre la normale consegna dell’avanzamento rimane invariata; valuta se sia necessario documentare il comportamento della notifica terminale.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
When a request completes, Protocol._onresponse deletes that request's progress handler. Any progress notification for the token that is processed afterwards falls into _onprogress, finds no handler, and is reported through _onerror:
Received a progress notification for an unknown token: {...}
Discarding the notification is reasonable — once the request is done, progress for it is moot. Raising a protocol error for it is not, because a server has no way to avoid producing that condition.
Why a server cannot avoid it
A server that reports progress for a batch operation naturally emits a terminal progress === total notification just before returning the result. Those two writes are adjacent by construction. Whether the client processes the notification before or after the response is a timing race the server does not control — and on a loaded machine it loses.
Concretely, in src/shared/protocol.ts:
// _onresponse
if (!isTaskResponse) {
this._progressHandlers.delete(messageId);
}
// _onprogress
const handler = this._progressHandlers.get(messageId);
if (!handler) {
this._onerror(new Error(`Received a progress notification for an unknown token: ...`));
return;
}
So any server emitting a terminal progress notification will intermittently cause onerror to fire in every client. For hosts that log or surface protocol errors, a well-behaved server ends up manufacturing spurious error noise on a successful operation.
Attempting to fix it server-side does not work. Awaiting the notification sends before returning the result orders the writes correctly, but cannot prevent the client from tearing down its handler before it dispatches them.
Reproduction
Server emits N progress notifications then the result, with no artificial spacing between them. Client:
const progress: unknown[] = [];
const errors: string[] = [];
client.onerror = (e) => errors.push(e.message);
await client.callTool({ name: "export", arguments: { /* 3 items */ } },
CallToolResultSchema, { onprogress: (p) => progress.push(p) });
Observed (server sent 4 notifications, all before the result):
received=1
errors=[
'Received a progress notification for an unknown token: {"method":"notifications/progress","params":{"progress":1,"total":3,...,"progressToken":1}}',
'...{"progress":2,...}',
'...{"progress":3,...}'
]
One delivered, three discarded with an error each. With ~100ms spacing between notifications the same code delivers all four — i.e. it is purely a timing race, not a protocol violation by either side.
Observed with @modelcontextprotocol/sdk 1.29.0 over stdio.
Suggested change
Treat "progress notification for a request that has just completed" as an expected, benign race rather than an error:
- don't route it to
_onerror; ignore it silently, or log at debug level; or - keep a short grace period after response for recently-completed tokens and drop matching notifications quietly.
Either removes the false error without changing the (sensible) decision not to deliver late progress.
Secondary question
Is there any supported way for a server to deliver a terminal progress notification reliably? If not, that is worth stating in the spec/docs, so server authors know the final progress === total frame is inherently best-effort and clients know not to build completion UI on it. Right now it looks reliable, and fails only under load.
- Lingua principale
- TypeScript
- Stelle
- 13.5k
- Fork
- 2.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 45
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di modelcontextprotocol/typescript-sdk
-
v1 v2
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
modelcontextprotocol/typescript-sdk#2946 ·
I maintainer di solito rispondono entro 1 giorno
-
[v2] URI template reserved expansions encode existing %HH sequences againForse già presa @takagibit18 l’ha presa 2 giorni fa. Apertav1 v2
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
modelcontextprotocol/typescript-sdk#2920 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[v2] URI template strict expansions leave !'()* unencodedForse già presa @takagibit18 l’ha presa 2 giorni fa. Apertav1 v2
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
modelcontextprotocol/typescript-sdk#2919 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Malformed params on spec request methods return -32603 Internal error instead of -32602 Invalid paramsForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertav1 v2
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
modelcontextprotocol/typescript-sdk#2916 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Unconditional `prompt=consent` (when `offline_access` in scope) blocks OAuth in Entra tenants with user consent disabled + admin consent grantedForse già presa @dasjideepak l’ha presa 9 giorni fa. Apertav1 v2
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
modelcontextprotocol/typescript-sdk#2867 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di modelcontextprotocol/typescript-sdk
Issue simili
-
Upgrade node-libzim to 4.7.0Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
openzim/mwoffliner#2933 ·
I maintainer di solito rispondono entro 1 giorno
-
Use the README category name for website links and submissionsForse già presa @dajiaohuang l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
birobirobiro/awesome-shadcn-ui#647 ·
I maintainer di solito rispondono entro 2 giorni
-
Add: Valea Prahovei TV RO SDApertacheck:passed streams:add
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
Urigo/accounter-fullstack#4604 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno