This message was deleted.
# ask-questions
w
This message was deleted.
g
I managed to minify the bundle so my lambda function goes under 1 MB. But now, I'm getting a
502 The Lambda function returned invalid JSON: The JSON output must be an object type
. Looks like the
handlerRequest
from
@growthbook/edge-lambda
returns
null
I am using this snippet:
Copy code
import { handleRequest } from "@growthbook/edge-lambda";

export async function handler(event, ctx, callback) {
  // Manually build your environment:
  const env = buildEnv();

  // Specify additional edge endpoint information:
  env.host = "<http://www.mysite.io|www.mysite.io>";

  // Uncomment for ease of testing locally - returns response instead of using callback():
  // env.returnResponse = true;

  handleRequest(event, callback, env);
}

function buildEnv() {
  // todo: define environment variables here
}
I just added my build env and set env.host.
h
handleRequest()
isn't supposed to return anything (unless you set
env.returnResponse = true;
). Instead its mean to call in internal callback.
g
Well it seemed to be a pure JS issue, since handleRequest is async, the handler actually returned
null
. Returning the promise solved this issue
h
yeah its a bit confusing. its a conditionally async function since we wanted to support both use cases
111 Views