feat(typert): propagate Remote cancellation
This commit is contained in:
@@ -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: [
|
||||
|
||||
Reference in New Issue
Block a user