News for hackers. Stuff that matters.
Re:Next.js Is Infuriating by quadhome on Tuesday September 02, 2025 @06:11AM (#45101055)
AsyncLocalStorage.enterWith is the wrong method; .enterWith changes the logger for across the *synchronous* execution. This doesn't matter if there's only one request happening at time-- like when you're testing locally. But that's why it didn't work on the actual project.

Use .run.

  return LoggerStorage.run(requestLogger(), () => {
      logger()?.debug({ url: request.url }, "Started processing request!");
      return NextResponse.next();
  });
Re:Next.js Is Infuriating by dminik on Tuesday September 02, 2025 @06:19AM (#45101118)
Nope, this doesn't work either.
Re:Next.js Is Infuriating by huksley on Tuesday September 02, 2025 @03:58PM (#45108244)
I have enterWith working perfectly with async/sync flow - all operations between request and response are logged with request id transparently. I am using custom server for both standalone build & dev server, nextjs 14, node 22.