feat(typert): propagate Remote cancellation

This commit is contained in:
imccyu
2026-08-06 18:13:15 +08:00
parent 9b63d72c94
commit 22bec5e63f
28 changed files with 280 additions and 66 deletions
+3
View File
@@ -562,6 +562,9 @@ function validateInvocation(descriptor: InvocationDescriptor): void {
}
validateCodec(parameter.codec, `${descriptor.id} parameter ${parameter.name}`)
}
if (descriptor.cancellation !== undefined && descriptor.cancellation.parameter !== 'signal') {
throw new Error(`typert: invocation "${descriptor.id}" cancellation parameter must be "signal"`)
}
if (descriptor.scope !== undefined) {
if (descriptor.invocation.kind !== 'direct') {
throw new Error(`typert: invocation "${descriptor.id}" Context receiver cannot declare a direct scope projection`)
@@ -411,6 +411,7 @@ describe('TypertRegistry', () => {
...invocation('@fixture/remote#strict'),
implementation: 'remoteExportCreate',
parameters: [{ name: 'request', wire: 'request', source: 'json', codec: strict }],
cancellation: { parameter: 'signal' },
result: strict,
}
const dispose = ctx.typert.remotes.register({ package: '@fixture/strict', descriptors: [strictInvocation] })
@@ -420,6 +421,10 @@ describe('TypertRegistry', () => {
[{ ...invocation(), id: '' }, 'invocation id'],
[{ ...invocation(), namespace: 'bad/name' }, 'namespace'],
[{ ...invocation(), implementation: 'bad/name' }, 'implementation method'],
[{
...invocation(),
cancellation: { parameter: 'abort' } as unknown as { readonly parameter: 'signal' },
}, 'cancellation parameter'],
[{
...invocation(),
parameters: [