Skip to content

Commit 39bc2f4

Browse files
committed
wip - attempted fixes
1 parent 26edd59 commit 39bc2f4

File tree

4 files changed

+41
-4
lines changed

4 files changed

+41
-4
lines changed

packages/nitro/src/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,14 @@ function addVirtualHandler(nitro: Nitro, route: string, buildPath: string) {
9191
// Nitro v3+ (native web handlers)
9292
nitro.options.virtual[`#${buildPath}`] = /* js */ `
9393
import { POST } from "${join(nitro.options.buildDir, buildPath)}";
94-
export default ({ req }) => POST(req);
94+
export default async ({ req }) => {
95+
try {
96+
return await POST(req);
97+
} catch (error) {
98+
console.error('Handler error:', error);
99+
return new Response('Internal Server Error', { status: 500 });
100+
}
101+
};
95102
`;
96103
}
97104
}

workbench/hono/nitro.config.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

workbench/hono/nitro.config.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { defineNitroConfig } from 'nitro/config';
2+
3+
export default defineNitroConfig({
4+
modules: ['workflow/nitro'],
5+
handlers: [
6+
{
7+
route: '/api/**',
8+
handler: './server.ts',
9+
},
10+
],
11+
});

workbench/hono/server.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,24 @@ app.post('/api/hook', async ({ req }) => {
176176
return Response.json(hook);
177177
});
178178

179-
export default app;
179+
app.post('/api/test-direct-step-call', async ({ req }) => {
180+
// This route tests calling step functions directly outside of any workflow context
181+
// After the SWC compiler changes, step functions in client mode have their directive removed
182+
// and keep their original implementation, allowing them to be called as regular async functions
183+
const { add } = await import('./workflows/99_e2e.js');
184+
185+
const body = await req.json();
186+
const { x, y } = body;
187+
188+
console.log(`Calling step function directly with x=${x}, y=${y}`);
189+
190+
// Call step function directly as a regular async function (no workflow context)
191+
const result = await add(x, y);
192+
console.log(`add(${x}, ${y}) = ${result}`);
193+
194+
return Response.json({ result });
195+
});
196+
197+
export default async (event: { req: Request }) => {
198+
return app.fetch(event.req);
199+
};

workbench/vite/routes/api/test-direct-step-call.post.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// After the SWC compiler changes, step functions in client mode have their directive removed
33
// and keep their original implementation, allowing them to be called as regular async functions
44

5-
import { add } from '../../workflows/99_e2e.js';
5+
import { add } from '../../workflows/99_e2e';
66

77
export default async ({ req }: { req: Request }) => {
88
const body = await req.json();

0 commit comments

Comments
 (0)