Repository navigation
Description
The TypeScript progress callback has been asynchronous since the runtime moved to rutis 0.23 (#1941, ADR 025 D4): a callback handed over by another plugin or the host is awaited outside a synchronous call, so each progress(...) is a frame the host dispatches on its own task. The public declaration and the authoring guide still describe a synchronous void call.
npm/plugin.d.ts:568declaresexport type MethodProgress = <T>(data: T & CheckedData<T>) => void;.docs/typescript-plugin-authoring.md:584showsprogress({ phase: 'started' });withoutawait.
The flake in #2082 is the observable consequence: a method that sends started and then settled without awaiting either lets the two notices race, so a client can receive settled first or lose started when the reply closes the progress channel. #2083 fixed the fixture behind that failure and left the type and the guide as the separate decision this issue takes.
Both reviews on #2083 asked for that part:
- eric8810 (review 6016766788) asked for a guide sentence stating "that ordering across successive progress calls requires awaiting each one".
- zerob13 (review 6016801609) wrote "The authoring example and
MethodProgressreturn type can be clarified separately."
The change has three parts:
npm/plugin.d.ts:MethodProgressreturnsPromise<void>, so the declaration matches the runtime the callback talks to.docs/typescript-plugin-authoring.md: the session method example awaits the call, and the text states the two cases that need it, keeping several progress notices in order and making sure a notice is queued before the method returns and the reply closes the channel.runtime/plugin-sdk.test.mjs: the compiled example asserts thatprogress(...)is aPromise<void>and keeps the calls that ignore the result, and the synchronous stubs passed toMethodHandlerandSessionMethodHandlerbecomeasync () => {}.
Effect on code outside this repository: a plugin that calls progress(...) without awaiting it still type-checks under tsc --strict, so the guide, not the type, has to say when to await. Code that stores the result in a Promise<void> fails with TS2322 today, and a unit test that passes a synchronous stub as the progress callback fails to compile with TS2345 after the change. A project that enables the typescript-eslint no-floating-promises rule starts reporting progress calls it does not await.
Activity
docs(plugin): record the progress callback's promise and its breaking…
test(runtime): pin the progress callback's promise result
types(plugin): return a promise from MethodProgress
test(runtime): make the Session method stub asynchronous