Skip to content

Commit 92f457f

Browse files
committed
Fix linting
1 parent f581aab commit 92f457f

4 files changed

Lines changed: 55 additions & 24 deletions

File tree

packages/test/src/test-random-streams.ts

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ async function driveWorkflow(
190190

191191
for (;;) {
192192
if (completion.failed) {
193-
throw new Error(`Workflow ${workflowType} failed unexpectedly: ${completion.failed.failure?.message ?? 'unknown error'}`);
193+
throw new Error(
194+
`Workflow ${workflowType} failed unexpectedly: ${completion.failed.failure?.message ?? 'unknown error'}`
195+
);
194196
}
195197

196198
const startedTimers = (completion.successful?.commands ?? []).flatMap((command) =>
@@ -251,7 +253,10 @@ test.serial('workflowRandom exposes the main workflow random sequence', async (t
251253

252254
test.serial('plugin named streams do not consume the workflow random stream', async (t) => {
253255
const baseline = extractNumbers(await driveWorkflow(t.context, 'randomStreamMainBaselineWithSleep'), 'workflow');
254-
const actual = extractNumbers(await driveWorkflow(t.context, 'randomStreamPluginNamedStreamDoesNotConsumeMain'), 'workflow');
256+
const actual = extractNumbers(
257+
await driveWorkflow(t.context, 'randomStreamPluginNamedStreamDoesNotConsumeMain'),
258+
'workflow'
259+
);
255260
t.deepEqual(actual, baseline);
256261
});
257262

@@ -268,7 +273,10 @@ test.serial('plugin named streams are isolated from one another', async (t) => {
268273
});
269274

270275
test.serial('plugin named streams preserve state across activations', async (t) => {
271-
const baseline = extractNumbers(await driveWorkflow(t.context, 'randomStreamPluginActivationBaseline'), 'plugin-activation');
276+
const baseline = extractNumbers(
277+
await driveWorkflow(t.context, 'randomStreamPluginActivationBaseline'),
278+
'plugin-activation'
279+
);
272280
const actual = extractNumbers(
273281
await driveWorkflow(t.context, 'randomStreamPluginActivationWithWorkflowInterference'),
274282
'plugin-activation'
@@ -278,9 +286,15 @@ test.serial('plugin named streams preserve state across activations', async (t)
278286

279287
test.serial('plugin named streams do not leak between workflows when the VM context is reused', async (t) => {
280288
await withReusableWorkflowCreator(t.context, async (driveContext) => {
281-
const baseline = extractNumbers(await driveWorkflow(driveContext, 'randomStreamPluginActivationBaseline'), 'plugin-activation');
289+
const baseline = extractNumbers(
290+
await driveWorkflow(driveContext, 'randomStreamPluginActivationBaseline'),
291+
'plugin-activation'
292+
);
282293
await driveWorkflow(driveContext, 'randomStreamPluginActivationWithWorkflowInterference');
283-
const actual = extractNumbers(await driveWorkflow(driveContext, 'randomStreamPluginActivationBaseline'), 'plugin-activation');
294+
const actual = extractNumbers(
295+
await driveWorkflow(driveContext, 'randomStreamPluginActivationBaseline'),
296+
'plugin-activation'
297+
);
284298
t.deepEqual(actual, baseline);
285299
});
286300
});
@@ -301,7 +315,10 @@ test.serial('plugin cached named streams do not leak between workflows when the
301315
});
302316

303317
test.serial('plugin-scoped randomness around internals next does not perturb workflow Math.random', async (t) => {
304-
const workflowBaseline = extractNumbers(await driveWorkflow(t.context, 'randomStreamMainBaselineWithSleep'), 'workflow');
318+
const workflowBaseline = extractNumbers(
319+
await driveWorkflow(t.context, 'randomStreamMainBaselineWithSleep'),
320+
'workflow'
321+
);
305322
const pluginBaseline = extractNumbers(
306323
await driveWorkflow(t.context, 'randomStreamPluginInternalsScopedBaseline'),
307324
'plugin-internals-scoped'
@@ -321,7 +338,10 @@ test.serial('plugin-scoped randomness does not leak between workflows when the V
321338
});
322339

323340
test.serial('plugin-scoped randomness survives await and restores before next runs', async (t) => {
324-
const workflowBaseline = extractNumbers(await driveWorkflow(t.context, 'randomStreamMainBaselineWithSleep'), 'workflow');
341+
const workflowBaseline = extractNumbers(
342+
await driveWorkflow(t.context, 'randomStreamMainBaselineWithSleep'),
343+
'workflow'
344+
);
325345
const pluginBaseline = extractNumbers(
326346
await driveWorkflow(t.context, 'randomStreamPluginScopedMathAcrossAwaitBaseline'),
327347
'plugin-scoped'
@@ -346,7 +366,10 @@ test.serial('workflowRandom keeps referring to the main workflow stream inside a
346366
});
347367

348368
test.serial('plugin-scoped uuid4 survives await and restores before next runs', async (t) => {
349-
const workflowBaseline = extractStrings(await driveWorkflow(t.context, 'randomStreamUuidBaselineWithSleep'), 'workflow-uuid');
369+
const workflowBaseline = extractStrings(
370+
await driveWorkflow(t.context, 'randomStreamUuidBaselineWithSleep'),
371+
'workflow-uuid'
372+
);
350373
const pluginBaseline = extractStrings(
351374
await driveWorkflow(t.context, 'randomStreamPluginScopedUuidAcrossAwaitBaseline'),
352375
'plugin-scoped-uuid'

packages/test/src/workflows/random-stream-interceptors.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
import { getRandomStream, uuid4, workflowInfo, workflowRandom, WorkflowInterceptors } from '@temporalio/workflow';
2-
import type { WorkflowRandomStream } from '@temporalio/workflow';
1+
import {
2+
getRandomStream,
3+
type WorkflowRandomStream,
4+
uuid4,
5+
workflowInfo,
6+
workflowRandom,
7+
WorkflowInterceptors,
8+
} from '@temporalio/workflow';
39

410
const pluginNamedStreamDoesNotConsumeMain = 'randomStreamPluginNamedStreamDoesNotConsumeMain';
511
const pluginNamedStreamNamespaceBaseline = 'randomStreamPluginNamedStreamNamespaceBaseline';
@@ -24,7 +30,10 @@ const pluginInternalsScopedWorkflowTypes = new Set([
2430
pluginInternalsScopedBaseline,
2531
pluginInternalsScopedWithWorkflowInterference,
2632
]);
27-
const pluginCachedStreamWorkflowTypes = new Set([pluginCachedStreamSingleActivation, pluginCachedStreamAcrossActivations]);
33+
const pluginCachedStreamWorkflowTypes = new Set([
34+
pluginCachedStreamSingleActivation,
35+
pluginCachedStreamAcrossActivations,
36+
]);
2837

2938
export const interceptors = (): WorkflowInterceptors => {
3039
// Keep the wrapper alive across activations to verify that updateRandomSeed
@@ -119,7 +128,7 @@ export const interceptors = (): WorkflowInterceptors => {
119128
default:
120129
return next(input);
121130
}
122-
}
131+
},
123132
},
124133
],
125134
outbound: [
@@ -136,7 +145,10 @@ export const interceptors = (): WorkflowInterceptors => {
136145
{
137146
activate(input, next) {
138147
if (pluginActivationWorkflowTypes.has(workflowInfo().workflowType)) {
139-
console.log('plugin-activation', getRandomStream('@temporalio/test/random-streams/plugin-activation').random());
148+
console.log(
149+
'plugin-activation',
150+
getRandomStream('@temporalio/test/random-streams/plugin-activation').random()
151+
);
140152
}
141153
if (pluginInternalsScopedWorkflowTypes.has(workflowInfo().workflowType)) {
142154
return getRandomStream('@temporalio/test/random-streams/plugin-internals-scoped').with(() => {

packages/workflow/src/interceptor-composition.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,11 @@ import { getActivator } from './global-attributes';
2323
* explicitly establishes its own scope.
2424
*/
2525
export function composeInterceptors<I, M extends keyof I>(interceptors: I[], method: M, next: Next<I, M>): Next<I, M> {
26-
return (((input: any) => {
26+
return ((input: any) => {
2727
const activator = getActivator();
28-
return (composeInterceptorsWith(
29-
interceptors,
30-
method,
31-
next,
32-
((wrappedNext) => activator.bindCurrentRandom(wrappedNext as any)) as <F extends (...args: any[]) => any>(
33-
next: F
34-
) => F
35-
) as any)(input);
36-
}) as unknown) as Next<I, M>;
28+
return (
29+
composeInterceptorsWith(interceptors, method, next, ((wrappedNext) =>
30+
activator.bindCurrentRandom(wrappedNext as any)) as <F extends (...args: any[]) => any>(next: F) => F) as any
31+
)(input);
32+
}) as unknown as Next<I, M>;
3733
}

packages/workflow/src/internals.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ export class Activator implements ActivationHandler {
529529

530530
public bindCurrentRandom<T extends (...args: any[]) => any>(fn: T): T {
531531
const randomSource = this.currentRandomStorage?.getStore();
532-
return (((...args: Parameters<T>) => this.withRandomSource(randomSource, () => fn(...args))) as unknown) as T;
532+
return ((...args: Parameters<T>) => this.withRandomSource(randomSource, () => fn(...args))) as unknown as T;
533533
}
534534

535535
public currentRandom(): number {

0 commit comments

Comments
 (0)