From 01b75e6506336ce269da20684bef4654bdf645f1 Mon Sep 17 00:00:00 2001 From: qixuan <58852732+GiveMe-A-Name@users.noreply.github.com> Date: Mon, 22 Jan 2024 14:36:12 +0800 Subject: [PATCH] fix(prod-server): ssr cache would return error result when use stream ssr (#5281) --- .changeset/short-wolves-battle.md | 6 ++++++ .../server/prod-server/src/libs/render/ssrCache/manager.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/short-wolves-battle.md diff --git a/.changeset/short-wolves-battle.md b/.changeset/short-wolves-battle.md new file mode 100644 index 000000000000..fc1c5d0d1a48 --- /dev/null +++ b/.changeset/short-wolves-battle.md @@ -0,0 +1,6 @@ +--- +'@modern-js/prod-server': patch +--- + +fix(prod-server): ssr cache would return error result when use stream ssr +fix(prod-server): 使用 stream ssr 时, ssr 缓存将会返回错误结果 diff --git a/packages/server/prod-server/src/libs/render/ssrCache/manager.ts b/packages/server/prod-server/src/libs/render/ssrCache/manager.ts index edab434eeb8a..17ec4bdf4d1d 100644 --- a/packages/server/prod-server/src/libs/render/ssrCache/manager.ts +++ b/packages/server/prod-server/src/libs/render/ssrCache/manager.ts @@ -70,7 +70,7 @@ export class CacheManager { await this.container.set(key, JSON.stringify(cache), { ttl }); return renderResult; } else { - let html: string; + let html = ''; const stream = new Transform({ write(chunk, _, callback) { html += chunk.toString();