Skip to content

Windows support #117

@ThomPuiman

Description

@ThomPuiman

I've attempted both to install workflow into an existing Next.JS app, as well as cloning the Birthday Card Generator app and in both cases experiencing the below error. It doesn't seem to discover any workflows despite being created with the directive and called from an API route.

  • Is workflow supported for Windows file systems?
  • If so, what could cause workflows not to be discovered?

The error:

ReferenceError: Workflow "workflow//C:\\dev\\birthday-card-generator\\app\\api\\generate\\route.ts//handleOrder" must be a function, but got "undefined" instead
    at file:///C:/dev/birthday-card-generator/node_modules/@workflow/core/dist/workflow.js:436:19
    at file:///C:/dev/birthday-card-generator/node_modules/@workflow/core/dist/telemetry.js:76:34
    at NoopContextManager.with (C:\dev\birthday-card-generator\node_modules\@opentelemetry\api\build\src\context\NoopContextManager.js:25:19)       
    at ContextAPI.with (C:\dev\birthday-card-generator\node_modules\@opentelemetry\api\build\src\api\context.js:60:46)
    at NoopTracer.startActiveSpan (C:\dev\birthday-card-generator\node_modules\@opentelemetry\api\build\src\trace\NoopTracer.js:65:31)
    at ProxyTracer.startActiveSpan (C:\dev\birthday-card-generator\node_modules\@opentelemetry\api\build\src\trace\ProxyTracer.js:36:24)
    at trace (file:///C:/dev/birthday-card-generator/node_modules/@workflow/core/dist/telemetry.js:74:19)
    at async file:///C:/dev/birthday-card-generator/node_modules/@workflow/core/dist/runtime.js:225:36
    at async file:///C:/dev/birthday-card-generator/node_modules/@workflow/core/dist/telemetry.js:76:28
    at async file:///C:/dev/birthday-card-generator/node_modules/@workflow/core/dist/telemetry.js:47:60
    at async file:///C:/dev/birthday-card-generator/node_modules/@workflow/core/dist/runtime.js:181:16
    at async file:///C:/dev/birthday-card-generator/node_modules/@workflow/world-local/dist/queue.js:103:34
    at async AppRouteRouteModule.do (C:\dev\birthday-card-generator\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:5:38696)   
    at async AppRouteRouteModule.handle (C:\dev\birthday-card-generator\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:5:45978)

My workflow:

import { NextResponse } from 'next/server';
import { FatalError } from 'workflow';
import { start } from 'workflow/api';

export const POST = async (request: Request): Promise<NextResponse> => {
  try {
    const body = await request.json();

    const values = await start(handleOrder, [body]);
    return NextResponse.json(values);
  } catch (error) {
    const message = error instanceof Error ? error.message : 'Unknown error';
    const isFatal = error instanceof FatalError;

    return NextResponse.json(
      {
        error: message,
        fatal: isFatal,
      },
      { status: isFatal ? 400 : 500 }
    );
  }
};

const handleOrder = async (data: any) => {
  'use workflow';
  await handleStep();
  // Workflow logic goes here
  return { status: 'success', data };
}

const handleStep = async () => {
  'use step';
  await new Promise(resolve => setTimeout(resolve, 10000));
  // Step logic goes here
  console.log('Step executed');
}

Metadata

Metadata

Labels

bugSomething isn't workinghelp wantedExtra attention is needed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions