Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions packages/angular/ssr/src/utils/ng.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,16 @@ export async function renderAngular(
await applicationRef.whenStable();

return {
content: async () => {
try {
return renderInternal(platformRef, applicationRef);
} finally {
await asyncDestroyPlatform(platformRef);
}
},
content: () =>
new Promise<string>((resolve, reject) => {
// Defer rendering to the next event loop iteration to avoid blocking, as most operations in `renderInternal` are synchronous.
setTimeout(() => {
renderInternal(platformRef, applicationRef)
.then(resolve)
.catch(reject)
.finally(() => void asyncDestroyPlatform(platformRef));
}, 0);
}),
};
} catch (error) {
await asyncDestroyPlatform(platformRef);
Expand Down