From 825d8f2683bd3692e5b2edbd702cbbe11155fcae Mon Sep 17 00:00:00 2001 From: Shubham Date: Thu, 12 Nov 2026 23:44:47 +0530 Subject: [PATCH 1/5] fix(plugin): preserve Activity and Nexus client interceptors --- packages/plugin/src/plugin.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/plugin/src/plugin.ts b/packages/plugin/src/plugin.ts index 929b0bc1c..9c7ac0b9f 100644 --- a/packages/plugin/src/plugin.ts +++ b/packages/plugin/src/plugin.ts @@ -269,6 +269,8 @@ function resolveClientInterceptors( modernWorkflowInterceptors(parameter?.workflow) ), schedule: tryConcat(existing?.schedule, parameter?.schedule), + activity: tryConcat(existing?.activity, parameter?.activity), + nexus: tryConcat(existing?.nexus, parameter?.nexus), })); } From 3163cef4921ca491dfba158b4f55f9027e1e67b8 Mon Sep 17 00:00:00 2001 From: Shubham Date: Thu, 12 Nov 2026 23:45:41 +0530 Subject: [PATCH 2/5] test(plugin): cover client interceptor merging --- .../src/test-plugin-client-interceptors.ts | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 packages/test/src/test-plugin-client-interceptors.ts diff --git a/packages/test/src/test-plugin-client-interceptors.ts b/packages/test/src/test-plugin-client-interceptors.ts new file mode 100644 index 000000000..6e85862d9 --- /dev/null +++ b/packages/test/src/test-plugin-client-interceptors.ts @@ -0,0 +1,71 @@ +import test from 'ava'; +import type { ClientInterceptors } from '@temporalio/client'; +import { SimplePlugin } from '@temporalio/plugin'; + +const first = { start: async () => undefined }; +const second = { start: async () => undefined }; + +// Object identity and order matter: these interceptors must execute as one chain. +function interceptors(marker: object): ClientInterceptors { + return { + workflow: [marker], + schedule: [marker], + activity: [marker], + nexus: [marker], + }; +} + +for (const path of ['client', 'worker', 'replay'] as const) { + for (const existing of [false, true]) { + for (const supplied of [false, true]) { + test(`SimplePlugin ${path} preserves all client interceptor families (existing=${existing}, plugin=${supplied})`, (t) => { + const original = existing ? interceptors(first) : undefined; + const addition = supplied ? interceptors(second) : undefined; + const plugin = new SimplePlugin({ + name: 'interceptor-merge', + ...(path === 'client' ? { clientInterceptors: addition } : { workerInterceptors: { client: addition } }), + }); + let actual: ClientInterceptors | undefined; + if (path === 'client') { + actual = plugin.configureClient({ interceptors: original }).interceptors; + } else if (path === 'worker') { + actual = plugin.configureWorker({ taskQueue: 'unused', interceptors: { client: original } }).interceptors + ?.client; + } else { + actual = plugin.configureReplayWorker({ + workflowBundle: { code: '' }, + interceptors: { client: original }, + }).interceptors?.client; + } + const expected = [...(existing ? [first] : []), ...(supplied ? [second] : [])]; + for (const family of ['workflow', 'schedule', 'activity', 'nexus'] as const) { + t.deepEqual(actual?.[family] ?? [], expected); + } + // Configuration must not append into either caller-owned array. + if (original) t.deepEqual(original, interceptors(first)); + if (addition) t.deepEqual(addition, interceptors(second)); + }); + } + } +} + +test('SimplePlugin preserves Activity and Nexus interceptors when another family is configured', (t) => { + const original: ClientInterceptors = { activity: [{}], nexus: [{}] }; + const plugin = new SimplePlugin({ name: 'workflow-only', clientInterceptors: { workflow: [{}] } }); + const actual = plugin.configureClient({ interceptors: original }).interceptors; + t.is(actual?.activity, original.activity); + t.is(actual?.nexus, original.nexus); +}); + +test('SimplePlugin leaves function-based client interceptor configuration in control', (t) => { + const original = interceptors(first); + const replacement = interceptors(second); + const plugin = new SimplePlugin({ + name: 'custom-merge', + clientInterceptors: (current) => { + t.is(current, original); + return replacement; + }, + }); + t.is(plugin.configureClient({ interceptors: original }).interceptors, replacement); +}); From 086b2aaa0dac84075ec501e88e74e9c5af135a9f Mon Sep 17 00:00:00 2001 From: Shubham Date: Thu, 12 Nov 2026 23:46:15 +0530 Subject: [PATCH 3/5] docs(changelog): note client interceptor merge fix --- changelog/fixed/tap-dancing-interceptors.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/fixed/tap-dancing-interceptors.md diff --git a/changelog/fixed/tap-dancing-interceptors.md b/changelog/fixed/tap-dancing-interceptors.md new file mode 100644 index 000000000..8bb0d3861 --- /dev/null +++ b/changelog/fixed/tap-dancing-interceptors.md @@ -0,0 +1 @@ +Preserve and append Activity and Nexus client interceptors when SimplePlugin merges client or worker client configuration. From efe67defbaaf864cbb1019cef0f92f4855d73630 Mon Sep 17 00:00:00 2001 From: Chris Olszewski Date: Fri, 13 Nov 2026 11:09:06 -0500 Subject: [PATCH 4/5] chore: move plugin test to plugin package --- packages/plugin/package.json | 13 +++++++++++-- .../src/__tests__/test-client-interceptors.ts} | 2 +- pnpm-lock.yaml | 3 +++ 3 files changed, 15 insertions(+), 3 deletions(-) rename packages/{test/src/test-plugin-client-interceptors.ts => plugin/src/__tests__/test-client-interceptors.ts} (98%) diff --git a/packages/plugin/package.json b/packages/plugin/package.json index c55e1c0cc..4f73c876a 100644 --- a/packages/plugin/package.json +++ b/packages/plugin/package.json @@ -13,12 +13,19 @@ "author": "Temporal Technologies Inc. ", "license": "MIT", "scripts": { - "build": "tsc --build" + "build": "tsc --build", + "test": "tsx ../../scripts/ava-ci.ts ./lib/__tests__/test-*.js" + }, + "ava": { + "timeout": "60s", + "concurrency": 1, + "workerThreads": false }, "devDependencies": { "@temporalio/client": "workspace:*", "@temporalio/common": "workspace:*", "@temporalio/worker": "workspace:*", + "ava": "^5.3.1", "nexus-rpc": "^0.0.3" }, "bugs": { @@ -38,6 +45,8 @@ }, "files": [ "src", - "lib" + "lib", + "!src/__tests__", + "!lib/__tests__" ] } diff --git a/packages/test/src/test-plugin-client-interceptors.ts b/packages/plugin/src/__tests__/test-client-interceptors.ts similarity index 98% rename from packages/test/src/test-plugin-client-interceptors.ts rename to packages/plugin/src/__tests__/test-client-interceptors.ts index 6e85862d9..d4cc69760 100644 --- a/packages/test/src/test-plugin-client-interceptors.ts +++ b/packages/plugin/src/__tests__/test-client-interceptors.ts @@ -1,6 +1,6 @@ import test from 'ava'; import type { ClientInterceptors } from '@temporalio/client'; -import { SimplePlugin } from '@temporalio/plugin'; +import { SimplePlugin } from '../plugin'; const first = { start: async () => undefined }; const second = { start: async () => undefined }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 640f84dfb..a167882ec 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -697,6 +697,9 @@ importers: '@temporalio/worker': specifier: workspace:* version: link:../worker + ava: + specifier: ^5.3.1 + version: 5.3.1 nexus-rpc: specifier: ^0.0.3 version: 0.0.3 From cd3cf5d55bfa13fdc5a57b177df71452b23ca50b Mon Sep 17 00:00:00 2001 From: Chris Olszewski Date: Fri, 13 Nov 2026 11:19:28 -0500 Subject: [PATCH 5/5] chore: simplify tests --- .../src/__tests__/test-client-interceptors.ts | 76 +++++-------------- 1 file changed, 21 insertions(+), 55 deletions(-) diff --git a/packages/plugin/src/__tests__/test-client-interceptors.ts b/packages/plugin/src/__tests__/test-client-interceptors.ts index d4cc69760..c55a64b3e 100644 --- a/packages/plugin/src/__tests__/test-client-interceptors.ts +++ b/packages/plugin/src/__tests__/test-client-interceptors.ts @@ -2,64 +2,30 @@ import test from 'ava'; import type { ClientInterceptors } from '@temporalio/client'; import { SimplePlugin } from '../plugin'; -const first = { start: async () => undefined }; -const second = { start: async () => undefined }; - -// Object identity and order matter: these interceptors must execute as one chain. -function interceptors(marker: object): ClientInterceptors { - return { - workflow: [marker], - schedule: [marker], - activity: [marker], - nexus: [marker], - }; -} - -for (const path of ['client', 'worker', 'replay'] as const) { - for (const existing of [false, true]) { - for (const supplied of [false, true]) { - test(`SimplePlugin ${path} preserves all client interceptor families (existing=${existing}, plugin=${supplied})`, (t) => { - const original = existing ? interceptors(first) : undefined; - const addition = supplied ? interceptors(second) : undefined; - const plugin = new SimplePlugin({ - name: 'interceptor-merge', - ...(path === 'client' ? { clientInterceptors: addition } : { workerInterceptors: { client: addition } }), - }); - let actual: ClientInterceptors | undefined; - if (path === 'client') { - actual = plugin.configureClient({ interceptors: original }).interceptors; - } else if (path === 'worker') { - actual = plugin.configureWorker({ taskQueue: 'unused', interceptors: { client: original } }).interceptors - ?.client; - } else { - actual = plugin.configureReplayWorker({ - workflowBundle: { code: '' }, - interceptors: { client: original }, - }).interceptors?.client; - } - const expected = [...(existing ? [first] : []), ...(supplied ? [second] : [])]; - for (const family of ['workflow', 'schedule', 'activity', 'nexus'] as const) { - t.deepEqual(actual?.[family] ?? [], expected); - } - // Configuration must not append into either caller-owned array. - if (original) t.deepEqual(original, interceptors(first)); - if (addition) t.deepEqual(addition, interceptors(second)); - }); - } - } -} +test('SimplePlugin appends Activity and Nexus client interceptors', (t) => { + const existingActivity = {}; + const existingNexus = {}; + const pluginActivity = {}; + const pluginNexus = {}; + const plugin = new SimplePlugin({ + name: 'interceptor-merge', + clientInterceptors: { activity: [pluginActivity], nexus: [pluginNexus] }, + }); + const actual = plugin.configureClient({ + interceptors: { activity: [existingActivity], nexus: [existingNexus] }, + }).interceptors; -test('SimplePlugin preserves Activity and Nexus interceptors when another family is configured', (t) => { - const original: ClientInterceptors = { activity: [{}], nexus: [{}] }; - const plugin = new SimplePlugin({ name: 'workflow-only', clientInterceptors: { workflow: [{}] } }); - const actual = plugin.configureClient({ interceptors: original }).interceptors; - t.is(actual?.activity, original.activity); - t.is(actual?.nexus, original.nexus); + t.is(actual?.activity?.length, 2); + t.is(actual?.activity?.[0], existingActivity); + t.is(actual?.activity?.[1], pluginActivity); + t.is(actual?.nexus?.length, 2); + t.is(actual?.nexus?.[0], existingNexus); + t.is(actual?.nexus?.[1], pluginNexus); }); -test('SimplePlugin leaves function-based client interceptor configuration in control', (t) => { - const original = interceptors(first); - const replacement = interceptors(second); +test('SimplePlugin clientInterceptors overrides default behavior', (t) => { + const original: ClientInterceptors = { activity: [{}], nexus: [{}] }; + const replacement: ClientInterceptors = { activity: [{}], nexus: [{}] }; const plugin = new SimplePlugin({ name: 'custom-merge', clientInterceptors: (current) => {