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
8 changes: 8 additions & 0 deletions .changeset/spicy-rivers-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@workflow/sveltekit": patch
"@workflow/builders": patch
"@workflow/nitro": patch
"@workflow/core": patch
---

Remove suppressUndefinedRejection from BaseBuilder
8 changes: 1 addition & 7 deletions packages/builders/src/base-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -671,26 +671,20 @@ export const POST = workflowEntrypoint(workflowCode);`;
* Creates a webhook handler bundle for resuming workflows via HTTP callbacks.
*
* @param bundle - If true, bundles dependencies (needed for Build Output API)
* @param suppressUndefinedRejections - If true, suppresses undefined rejections.
* This is a workaround to avoid crashing in local
* dev when context isn't set for waitUntil()
*/
protected async createWebhookBundle({
outfile,
bundle = false,
suppressUndefinedRejections = false,
}: {
outfile: string;
bundle?: boolean;
suppressUndefinedRejections?: boolean;
}): Promise<void> {
console.log('Creating webhook route');
await mkdir(dirname(outfile), { recursive: true });

// Create a static route that calls resumeWebhook
// This route works for both Next.js and Vercel Build Output API
const routeContent = `${suppressUndefinedRejections ? 'process.on("unhandledRejection", (reason) => { if (reason !== undefined) console.error("Unhandled rejection detected", reason); });\n' : ''}
import { resumeWebhook } from 'workflow/api';
const routeContent = `import { resumeWebhook } from 'workflow/api';

async function handler(request) {
const url = new URL(request.url);
Expand Down
7 changes: 6 additions & 1 deletion packages/core/src/runtime/resume-hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ export async function resumeHook<T = any>(
ops,
hook.runId
);
waitUntil(Promise.all(ops));
// NOTE: Workaround instead of injecting catching undefined unhandled rejections in webhook bundle
waitUntil(
Promise.all(ops).catch((err) => {
if (err !== undefined) throw err;
})
);

// Create a hook_received event with the payload
await world.events.create(hook.runId, {
Expand Down
1 change: 0 additions & 1 deletion packages/nitro/src/builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export class LocalBuilder extends BaseBuilder {
await this.createWebhookBundle({
outfile: webhookRouteFile,
bundle: false,
suppressUndefinedRejections: true,
});
}
}
1 change: 0 additions & 1 deletion packages/sveltekit/src/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ export const POST = async ({request}) => {
await this.createWebhookBundle({
outfile: webhookRouteFile,
bundle: false, // SvelteKit will handle bundling
suppressUndefinedRejections: true,
});

// Post-process the generated file to wrap with SvelteKit request converter
Expand Down
Loading