Skip to content

Commit f45fc26

Browse files
VIA-831 LC flush hydrator log to capture final entry
1 parent 4320dbc commit f45fc26

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/_lambda/content-cache-hydrator/handler.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,21 @@ const runContentCacheHydrator = async (event: ContentCacheHydratorEvent) => {
191191
}
192192
};
193193

194+
const flushLogs = () =>
195+
new Promise<void>((resolve) => {
196+
logger.flush(() => resolve());
197+
});
198+
194199
export const handler = async (event: object, context: Context): Promise<void> => {
195200
const requestContext: RequestContext = {
196201
traceId: context.awsRequestId,
197202
nextUrl: "",
198203
sessionId: "content-cache-hydrator",
199204
};
200205

201-
await asyncLocalStorage.run(requestContext, () => runContentCacheHydrator(event));
206+
try {
207+
await asyncLocalStorage.run(requestContext, () => runContentCacheHydrator(event));
208+
} finally {
209+
await flushLogs();
210+
}
202211
};

0 commit comments

Comments
 (0)