Skip to content

Commit

Permalink
await all logs before closing edge function
Browse files Browse the repository at this point in the history
  • Loading branch information
konstrybakov committed Jul 25, 2024
1 parent 547a6ab commit eb77d00
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/api/email/jobs/route.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Jobs from '@/emails/jobs'
import { queryGetJobs } from '@/lib/db/queries'
import { logger } from '@/lib/logger'
import { logger, transport } from '@/lib/logger'
import { render } from '@react-email/render'
import { ReasonPhrases, StatusCodes } from 'http-status-codes'
import { headers } from 'next/headers'
Expand Down Expand Up @@ -61,5 +61,9 @@ export const GET = async () => {
{ error },
{ status: StatusCodes.INTERNAL_SERVER_ERROR },
)
} finally {
logger.info('Finished `send-email` cron job')

await transport.close()
}
}
2 changes: 1 addition & 1 deletion lib/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if (process.env.NODE_ENV === 'production') {
})
}

const transport = pino.transport({
export const transport = pino.transport({
targets,
})

Expand Down

0 comments on commit eb77d00

Please sign in to comment.