From ccc3dc93709da608cae1c79da169f180903190c5 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Tue, 11 Feb 2025 07:40:17 +0100 Subject: [PATCH] Update(was): sync with the new handler API See https://github.com/opennextjs/opennextjs-aws/pull/733 --- pages/aws/config/custom_overrides.mdx | 2 +- pages/aws/config/overrides/wrapper.mdx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pages/aws/config/custom_overrides.mdx b/pages/aws/config/custom_overrides.mdx index 0f1c66e..7c86e75 100644 --- a/pages/aws/config/custom_overrides.mdx +++ b/pages/aws/config/custom_overrides.mdx @@ -238,7 +238,7 @@ const handler: WrapperHandler = }, }; - const response = await handler(internalEvent, fakeStream); + const response = await handler(internalEvent, { streamCreator: fakeStream }); response.headers["x-wrapper"] = "hi"; return converter.convertTo(response, event); diff --git a/pages/aws/config/overrides/wrapper.mdx b/pages/aws/config/overrides/wrapper.mdx index 33543a3..1728b3c 100644 --- a/pages/aws/config/overrides/wrapper.mdx +++ b/pages/aws/config/overrides/wrapper.mdx @@ -7,7 +7,7 @@ Couple of things to note : - If you want to use streaming (for the `node` runtime of next), you'll need to create a `StreamCreator` and pass it to the `handler`. You can find some example in the [node](https://github.com/opennextjs/opennextjs-aws/blob/main/packages/open-next/src/overrides/wrappers/node.ts) or [aws-lambda-streaming](https://github.com/opennextjs/opennextjs-aws/blob/main/packages/open-next/src/overrides/wrappers/aws-lambda-streaming.ts) wrapper. - If you don't use streaming (like in the default `aws-lambda` wrapper), you may still need to provide a fake `StreamCreator` to the `handler` to avoid a weird issue with Node itself (see [here](https://github.com/opennextjs/opennextjs-aws/blob/f685ddea8f8a5c82591dc02713aff7138f2d9896/packages/open-next/src/overrides/wrappers/aws-lambda.ts#L49-L65) for an example and a more thorough explanation). - If you use the `edge` runtime of Next (either for the external middleware or for an `edge` route or page), you don't need the `StreamCreator` at all. -- If you are in a serverless environment and it supports `waitUntil`, you should define it here(see [here](https://github.com/opennextjs/opennextjs-aws/blob/b0b1f7776b41612d2638a33e3c9ced8c42afab0a/packages/open-next/src/overrides/wrappers/cloudflare-node.ts#L80). This might not be necessary depending on where you run it (for example the `aws-lambda-streaming` or the `node` wrapper doesn't need it.) +- If you are in a serverless environment and it supports `waitUntil`, you should pass it to the handler as it is done in the [cloudflare-edge wrapper](https://github.com/opennextjs/opennextjs-aws/blob/87b59e59a8a0bf1e83d2d1df9efa0ad3bfc912f5/packages/open-next/src/overrides/wrappers/cloudflare-edge.ts#L65-L67). This might not be necessary depending on where you run it (for example the `aws-lambda-streaming` or the `node` wrapper doesn't need it.) ## Included Wrappers