Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] logs are not showing up sometimes for Vercel edge function (pages router) #175

Open
GorvGoyl opened this issue Nov 29, 2023 · 7 comments

Comments

@GorvGoyl
Copy link

GorvGoyl commented Nov 29, 2023

Sometimes logs do not show up and I'd like to know if this is a known bug or if am I doing something wrong. I'm on pages router and followed this guide: https://github.com/axiomhq/next-axiom/blob/v0.x/README.md

//  "next-axiom": "0.18.1",
import { AxiomRequest, withAxiom } from "next-axiom";

export const config = {
  runtime: "edge",
};

async function handler(req: AxiomRequest) {
  const console = req.log.with({ traceId: "xxx" });

  console.info("inside model api");

  console.info("model data", {
    model: "text-davinci-002-render",
  });

  return new Response(
    JSON.stringify({
      model: "text-davinci-002-render",
    }),
    {
      status: 200,
      headers: {
        "content-type": "application/json",
      },
    }
  );
}
export default withAxiom(handler);

other event logs are always shown, it's the console.info logs that are missing.

screenshot 2023-11-29 at 18 37 58@2x

@GorvGoyl GorvGoyl changed the title logs are not showing up sometimes for Vercel edge function (pages router) [bug] logs are not showing up sometimes for Vercel edge function (pages router) Nov 29, 2023
@bahlo
Copy link
Member

bahlo commented Nov 29, 2023

Hey hey, is this on a production environment?

@GorvGoyl
Copy link
Author

GorvGoyl commented Nov 29, 2023

Hey hey, is this on a production environment?

for the preview environment but I have enabled the AXIOM env variable for all environments in case that's what you were wondering.

Also, I tried adding await console.flush(); in the api but still logs get missed in some function calls. As shown below, API was called 2 times but the info logs showed up only once.

image

@GorvGoyl
Copy link
Author

Hi, any update on this?

@josephp27
Copy link

same issue. when i do it locally no issues. When i deploy, this is happening on cloudflare pages. did you ever resolve?

@bahlo
Copy link
Member

bahlo commented Mar 26, 2024

does the same thing happen when you use the logger directly, without creating a child-logger using with?

@levi
Copy link

levi commented Mar 27, 2024

I dug into this and was able to get logging working fine with @cloudflare/next-on-pages.

What didn't work fine, which is what made me think there was an issue in the first place, is that isEdgeRuntime is false on Cloudflare workers and the logEdgeReport never gets called. @bahlo I'm not deeply familiar with the cloudflare worker runtime, is there a way we could easily identify it and include it in the isEdgeRuntime calculation?

@cjxe
Copy link

cjxe commented Sep 13, 2024

I dug into this and was able to get logging working fine with @cloudflare/next-on-pages.

@levi how?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants