Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions .changeset/angry-snails-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@builder.io/qwik': patch
---

Add a catch to the flush's write invocation to avoid server crash
2 changes: 1 addition & 1 deletion packages/qwik/src/core/render/ssr/render-ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

/** @public */
export type StreamWriter = {
write: (chunk: string) => void;
write: (chunk: string) => Promise<void>;
};

/** @public */
Expand Down Expand Up @@ -243,7 +243,7 @@
let value: AsyncGenerator;
if (isFunction(generator)) {
const v = generator({
write(chunk) {

Check failure on line 246 in packages/qwik/src/core/render/ssr/render-ssr.ts

View workflow job for this annotation

GitHub Actions / Build Qwik

Type '(chunk: string) => void' is not assignable to type '(chunk: string) => Promise<void>'.
stream.write(chunk);
stream.write(FLUSH_COMMENT);
},
Expand Down Expand Up @@ -951,7 +951,7 @@
return children.reduce((prevPromise: Promise<void> | undefined, child, index) => {
const buffer: string[] = [];
buffers.push(buffer);
const localStream: StreamWriter = prevPromise

Check failure on line 954 in packages/qwik/src/core/render/ssr/render-ssr.ts

View workflow job for this annotation

GitHub Actions / Build Qwik

Type '{ write(chunk: string): void; }' is not assignable to type 'StreamWriter'.
? {
write(chunk) {
if (currentIndex === index) {
Expand Down
5 changes: 4 additions & 1 deletion packages/qwik/src/server/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@
const resolvedManifest = resolveManifest(opts.manifest);
function flush() {
if (buffer) {
nativeStream.write(buffer);
nativeStream.write(buffer).catch((e) => {
console.error(`Could not write buffer: ${buffer.slice(0, 200)}...`);
console.error(e);
});
buffer = '';
bufferSize = 0;
networkFlushes++;
Expand All @@ -68,7 +71,7 @@
switch (inOrderStreaming.strategy) {
case 'disabled':
stream = {
write: enqueue,

Check failure on line 74 in packages/qwik/src/server/render.ts

View workflow job for this annotation

GitHub Actions / Build Qwik

Type '(chunk: string) => void' is not assignable to type '(chunk: string) => Promise<void>'.
};
break;
case 'direct':
Expand All @@ -80,7 +83,7 @@
const minimunChunkSize = inOrderStreaming.maximunChunk ?? 0;
const initialChunkSize = inOrderStreaming.maximunInitialChunk ?? 0;
stream = {
write(chunk) {

Check failure on line 86 in packages/qwik/src/server/render.ts

View workflow job for this annotation

GitHub Actions / Build Qwik

Type '(chunk: string) => void' is not assignable to type '(chunk: string) => Promise<void>'.
if (chunk === '<!--qkssr-f-->') {
forceFlush ||= true;
} else if (chunk === '<!--qkssr-pu-->') {
Expand Down Expand Up @@ -253,7 +256,7 @@
): Promise<RenderToStringResult> {
const chunks: string[] = [];
const stream: StreamWriter = {
write(chunk) {

Check failure on line 259 in packages/qwik/src/server/render.ts

View workflow job for this annotation

GitHub Actions / Build Qwik

Type '(chunk: string) => void' is not assignable to type '(chunk: string) => Promise<void>'.
chunks.push(chunk);
},
};
Expand Down
Loading