Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,11 @@
if (!timeoutMs || timeoutMs <= 0) return this.doExecute();

let timer: NodeJS.Timeout | undefined;
let hasTimeoutFired = false;
const execPromise = this.doExecute();

execPromise.catch(err => {
if (!hasTimeoutFired) return;
this.context.logger.info('Step work rejected after timeout — result discarded', {
runId: this.context.runId,
stepId: this.context.stepId,
Expand All @@ -188,7 +190,10 @@
return await Promise.race([
execPromise,
new Promise<never>((_, reject) => {
timer = setTimeout(() => reject(new StepTimeoutError(timeoutMs)), timeoutMs);
timer = setTimeout(() => {
hasTimeoutFired = true;
reject(new StepTimeoutError(timeoutMs));
}, timeoutMs);
}),
]);
} finally {
Expand Down Expand Up @@ -218,7 +223,7 @@
const execution = await this.findPendingExecution<TExec>(type);

if (pendingData !== undefined && execution) {
const schema = patchBodySchemas[execution.type]!;

Check warning on line 226 in packages/workflow-executor/src/executors/base-step-executor.ts

View workflow job for this annotation

GitHub Actions / Linting & Testing (workflow-executor)

Forbidden non-null assertion
const parsed = schema.safeParse(pendingData);

if (!parsed.success) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,21 @@ describe('BaseStepExecutor', () => {
process.off('unhandledRejection', unhandled);
}
}, 5_000);

it('does not log discard message when step rejects before timeout', async () => {
const logger = makeMockLogger();
const executor = new TestableExecutor(
makeContext({ stepTimeoutMs: 5_000, logger }),
new Error('normal step error'),
);

await executor.execute();

expect(logger.info).not.toHaveBeenCalledWith(
'Step work rejected after timeout — result discarded',
expect.anything(),
);
});
});

describe('activity log lifecycle', () => {
Expand Down
Loading