diff --git a/.changeset/spicy-rivers-call.md b/.changeset/spicy-rivers-call.md new file mode 100644 index 000000000..57a093ae1 --- /dev/null +++ b/.changeset/spicy-rivers-call.md @@ -0,0 +1,8 @@ +--- +"@workflow/sveltekit": patch +"@workflow/builders": patch +"@workflow/nitro": patch +"@workflow/core": patch +--- + +Remove suppressUndefinedRejection from BaseBuilder diff --git a/packages/builders/src/base-builder.ts b/packages/builders/src/base-builder.ts index 9715d5e20..4319251d2 100644 --- a/packages/builders/src/base-builder.ts +++ b/packages/builders/src/base-builder.ts @@ -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 { 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); diff --git a/packages/core/src/runtime/resume-hook.ts b/packages/core/src/runtime/resume-hook.ts index 6659ceee1..9ae5146b8 100644 --- a/packages/core/src/runtime/resume-hook.ts +++ b/packages/core/src/runtime/resume-hook.ts @@ -81,7 +81,12 @@ export async function resumeHook( 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, { diff --git a/packages/nitro/src/builders.ts b/packages/nitro/src/builders.ts index edda41250..8b36d24d1 100644 --- a/packages/nitro/src/builders.ts +++ b/packages/nitro/src/builders.ts @@ -68,7 +68,6 @@ export class LocalBuilder extends BaseBuilder { await this.createWebhookBundle({ outfile: webhookRouteFile, bundle: false, - suppressUndefinedRejections: true, }); } } diff --git a/packages/sveltekit/src/builder.ts b/packages/sveltekit/src/builder.ts index e26b568c5..52b4c8895 100644 --- a/packages/sveltekit/src/builder.ts +++ b/packages/sveltekit/src/builder.ts @@ -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