Bug Description
The execute() method in packages/core/src/lib/runtime.ts has two sets of const declarations in the same function scope. JavaScript const cannot be redeclared, so calling WorkflowRuntime.execute() throws a SyntaxError at parse time. This makes the entire workflow execution system non-functional.
This bug was introduced by PR #34 ("fix runtime tenant tracing events") which added a new execution loop (lines 81-129) but kept the existing retry-enabled loop (lines 132+) instead of replacing it. Both loops now declare const state and const results in the same scope.
Prerequisites
Steps to Reproduce
- Clone the repository and install dependencies with
pnpm install.
- Start the PulseStack runtime service.
- Send a
POST /api/runtime/executions request with any valid workflow payload:
{
"workflow": {
"id": "wf_test",
"name": "Test Workflow",
"version": "1.0.0",
"tenantId": "tenant_prod",
"correlationId": "corr_prod",
"metadata": {},
"steps": [
{ "id": "step1", "name": "Step 1", "kind": "tool", "dependsOn": [], "input": {} }
]
},
"input": {},
"initiatedBy": "test"
}
- Observe the server crash with:
SyntaxError: Identifier 'state' has already been declared
Expected Behavior
The workflow should execute successfully and return { executionId, traceId, output } containing the execution results.
Actual Behavior
The server throws a parse-time SyntaxError before any code executes. The method has two pairs of duplicate const declarations:
Lines 81-82 (first loop):
const state: Record<string, unknown> = { ...request.input };
const results: StepResult[] = [];
Lines 132-134 (second loop — same function scope):
const state: Record<string, unknown> = { ...request.input };
const retryState: Record<string, unknown> = {};
const results: StepResult[] = [];
Additionally, lines 84-129 contain ~50 lines of dead code from a prior implementation draft that is unreachable because the duplicate declarations cause a parse error first.
Diagnostic Information
Environment Details
System Logs & Stack Traces
SyntaxError: Identifier 'state' has already been declared
at wrapSafe (<node_internal/modules/cjs/loader>:1378:20)
at Module._compile (<node_internal/modules/cjs/loader>:1420:41)
Additional Context
The bug was introduced by the fix for issue #31 (PR #34). The developer added a new implementation block at lines 81-129 but neglected to remove the original block at lines 132+ that contains the same variable declarations. The fix is to delete lines 80-131 entirely, keeping only the retry-enabled version.
Bug Description
The
execute()method inpackages/core/src/lib/runtime.tshas two sets ofconstdeclarations in the same function scope. JavaScriptconstcannot be redeclared, so callingWorkflowRuntime.execute()throws aSyntaxErrorat parse time. This makes the entire workflow execution system non-functional.This bug was introduced by PR #34 ("fix runtime tenant tracing events") which added a new execution loop (lines 81-129) but kept the existing retry-enabled loop (lines 132+) instead of replacing it. Both loops now declare
const stateandconst resultsin the same scope.Prerequisites
mainbranch of PulseStack.Steps to Reproduce
pnpm install.POST /api/runtime/executionsrequest with any valid workflow payload:{ "workflow": { "id": "wf_test", "name": "Test Workflow", "version": "1.0.0", "tenantId": "tenant_prod", "correlationId": "corr_prod", "metadata": {}, "steps": [ { "id": "step1", "name": "Step 1", "kind": "tool", "dependsOn": [], "input": {} } ] }, "input": {}, "initiatedBy": "test" }SyntaxError: Identifier 'state' has already been declaredExpected Behavior
The workflow should execute successfully and return
{ executionId, traceId, output }containing the execution results.Actual Behavior
The server throws a parse-time
SyntaxErrorbefore any code executes. The method has two pairs of duplicateconstdeclarations:Lines 81-82 (first loop):
Lines 132-134 (second loop — same function scope):
Additionally, lines 84-129 contain ~50 lines of dead code from a prior implementation draft that is unreachable because the duplicate declarations cause a parse error first.
Diagnostic Information
Environment Details
mainbranch, post-PR fix runtime tenant tracing events #34System Logs & Stack Traces
Additional Context
The bug was introduced by the fix for issue #31 (PR #34). The developer added a new implementation block at lines 81-129 but neglected to remove the original block at lines 132+ that contains the same variable declarations. The fix is to delete lines 80-131 entirely, keeping only the retry-enabled version.