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

Why do I need to call log.flush() before returning on a server component? #214

Open
Dacaramo opened this issue Jul 17, 2024 · 1 comment

Comments

@Dacaramo
Copy link

I'm using the next-axiom library for Next.js and I'm trying to understand why does log.flush() needs to be called before returning on server components?

It will be great to know a little bit more about this function to really understand when to use it, that's what I'm proposing here, cause until know the docs of this library does not tell anything about that function, they only present a single use case out of 20 of more posible use cases.

Maybe you want to create a function that process errors and one of the tasks of that function is sending the error info to an Axiom dataset, so does that function will need to call log.flush() internally? What if I call this function multiple times on the server components? Does calling log.flush() multiple times will cause unwanted behavior?

Maybe you want to ingest data from middleware.ts, generateMetadata or any other context that is executed on the server, but that is not a server component, what do I do in those cases?

Do I need to call log.flush before throwing also?

It will be great to have this specified on the docs, thank you so much!

@radziminski
Copy link

On top of that, log.flush takes significant amount of time, so it also impacts server-components performance (as described here).

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

2 participants