Skip to content

Commit

Permalink
fix(gatsby): Handle renderToPipeableStream errors (#36555)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyhopp committed Sep 7, 2022
1 parent 42e241c commit 9c5eacf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions packages/gatsby/cache-dir/server-utils/writable-as-promise.js
Expand Up @@ -16,15 +16,21 @@ export class WritableAsPromise extends Writable {
})
}

_write(chunk, enc, cb) {
_write(chunk, _, next) {
this._output += chunk.toString()
next()
}

cb()
_destroy(error, next) {
if (error instanceof Error) {
this._deferred.reject(error)
} else {
next()
}
}

end() {
this._deferred.resolve(this._output)

this.destroy()
}

Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/cache-dir/static-entry.js
Expand Up @@ -294,7 +294,7 @@ export default async function staticPage({
pipe(writableStream)
},
onError(error) {
throw error
writableStream.destroy(error)
},
})

Expand Down

0 comments on commit 9c5eacf

Please sign in to comment.